`
aigo
  • 浏览: 2674817 次
  • 性别: Icon_minigender_1
  • 来自: 宜昌
社区版块
存档分类
最新评论

[UE4]GameMode, GameInstance, GameState, PlayerState的区别

UE4 
阅读更多

whats the deferent between gamestate and game instance

https://answers.unrealengine.com/questions/189120/whats-the-deferent-between-gamestate-and-game-inst.html

GameState is replicated extension of GameMode, since GameMode it self is not replicated and exists only on servers memory for security reasons. So GameState let clients access some game data which you would normally place in GameMode, primerly scores and match time, stuff that you usually see on scoreboard. This is only info that client will have and GameMode should have info which only server should know. You can ignore GameState if you creating single player only game.

 

GameInstance is a class that which state persists switching of levels, game mode switches etc. where classes like GameMode or PlayerController are being reset and any data stored in them is deleted and put to defaults again. Any data that you want to keep beyond levels and matches, for example "what player did in specific moment so you can have consequence on other level" should be placed here. This class is mainly helpful for single player games... but it can find uses in multi player too ;] 

 

The GameInstance is itself not replicated, and exists only on the Server, so its variables won't be replicated either. Your best place for something you'd want replicated from the GameInstance would be the GameState, which is replicated.

 

 

For UI of multiplayer game you should use GameState and PlayerState ofcorse

 

=================================================

GameInstance官方解释

https://wiki.unrealengine.com/Game_Instance,_Custom_Game_Instance_For_Inter-Level_Persistent_Data_Storage

One of the new UE4 engine features as of 4.4 is the Game Instance class!

This is a globally accessible instanced UObject that can store any data you want to be carried between levels!

Where formally you would have had to write out data to a config file or to binary file, to transfer between levels, now you can use the Game Instance class!

 

 

===========================================

GameMode vs GameState

https://answers.unrealengine.com/questions/122429/gamemode-vs-gamestate.html

They Are Very Different In Multiplayer Game

Game Mode = Only Exists on the server, and controls how players login to the match, and how player units are spawned. You can stop a player from joining a multiplayer game here, or know when a player has left. And again this actor only ever exists on the server.

 

Game State = Ideal for managing all aspects of a replicated world, such as world time, world object positions not owned by a player, AOE damage zones, neutral replicated gameplay elements of any kind.

 

This actor exists for client and server and allows for each client to know stuff about the world.

 

Again a great example is World time where you want the client to know what what the session / turn / current mission time is as propogated to each client from server calculations that are done in Game State class on the server, and replicated to each client using a replicated Time variable.

 

The bulk of actual game-time related stuff in multiplayer game has to be done in Game State if it is anything you want clients to know about locally :)

 

Rama

 

 

===========================================

Where should I create a manager class : in GameMode or GameState?

https://answers.unrealengine.com/questions/43894/a-manager-class-in-gamemode-or-gamestate.html

This is a bit confusing to me. UE alread has these 'manager' classes set up for you. All you have to do is use them.

You are tying to make manager classes to do the following:

Modify Gameplay - This should be done in the GameMode class

Update Scores - This should be done in the GameState class

Player Statistics - This should be done in the PlayerState class

Now all of these classes are replicated automatically. Check this out: Link to GameMode Docs.. .you can see that you set these all up for the engine to manage internally... you just use them.

What you are trying to do is implement a system that already exists.

Look at the Gameplay Framework Docs to get a better understanding of this.

Good 

 

 

===========================================

Gameplay Framework官方文档

https://docs.unrealengine.com/latest/INT/Gameplay/Framework/index.html

 

分享到:
评论

相关推荐

    GameState demo

    Port GameState Demo(use OIS) to OGRE SDK1.4.5 <br>the orignol demo is here tutorial : ... and it works well with OGRE SDK 1.4.5. I am very happy to share this code with you, if it is useful ...

    csgo-gamestate-spotify:聆听CS的原型

    反恐精英全球进攻游戏状态Spotify ...将gamestate_integration_glennserver_spotify.cfg文件复制到C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\cfg文件夹

    Unreal Engine 网络摘要

    例如,在一个射击游戏中,可以创建一个新的`GameMode`子类来实现特殊的重生机制或计分板逻辑。 ##### 示例及用法 本文档还提供了丰富的示例和实际用例,帮助开发者更好地理解如何在项目中应用上述概念和技术。这些...

    GAMESTATE_GROUP5

    4. **继承与多态**:利用Java的继承特性,我们可以创建一个抽象的GameState基类,然后让具体的如MenuState、PlayState等子类继承它,实现各自的状态逻辑。多态性允许我们用同一接口处理不同状态,提高代码的复用性和...

    Game_State

    在Game_State-master这个项目中,我们可以预见到源代码会包含上述提到的`GameState`接口或抽象类,各个具体状态类,以及`GameStateManager`类。通过阅读和理解这些代码,开发者可以学习到如何在Java中构建一个高效且...

    tictactoe-gamestate:井字游戏游戏状态

    4. **切换玩家**:每次玩家下完棋后,都需要切换到下一个玩家。一个`switchPlayer()`函数可以实现这一点,确保游戏的交替进行。 5. **游戏状态可视化**:为了帮助用户理解游戏当前情况,可能还需要一个`printBoard...

    Unity3D脚本:协同程序与状态机的Update混用设置等待时间2

    当`RoleAttack`协同程序的`WaitForSeconds`完成,控制权返回到协同程序,`gameState`被设置回`GameState.game`,游戏逻辑继续正常执行。这种机制确保了`RoleAttack`只执行一次,并且在等待2秒后正确地返回到游戏循环...

    PocketEngine:C ++中的游戏引擎

    掌上引擎C ++中的游戏引擎目前支持MacOS,iOS,...class Game : public GameState<Game> {public: GameWorld world; RenderSystem* renderer; GameObject* camera; GameObject* cube; float rotation; void Initializ

    pokercash-client:模拟扑克筹码的工具

    扑克现金PokerCash是一种开源远程工具,旨在替代玩德克萨斯州扑克游戏的扑克筹码。... GameState和PlayerData的数据结构: GameAPI和逻辑:即将推出: 在线多人在线版本的PokerCash正在开发中更好的样式和用户界面

    Stratego_GameState:Stratego的游戏状态作业

    4. **方法**:`GameState`类需要包含一系列的方法来执行游戏操作,如移动棋子、检查移动合法性、处理棋子间的交互(如碰撞检测)、更新游戏状态等。 5. **封装和继承**:为了保持代码的整洁和可维护性,可以将与...

    MF(俄罗斯方块)

    namespace KY_GAME { class ST_LOGO : public GameState , public Singleton<ST_LOGO>{ public: bool init() ; void paint(); void callFunc(); private: ST_LOGO(){}; ~ST_LOGO(){}; DECLARE_...

    MF(俄罗斯方块)

    namespace KY_GAME { class ST_LOGO : public GameState , public Singleton<ST_LOGO>{ public: bool init() ; void paint(); void callFunc(); private: ST_LOGO(){}; ~ST_LOGO(){}; DECLARE_...

    node-csgo-gsi::water_pistol:零依赖反恐精英

    节点csgo-gsi 反恐精英:node.js的全球进攻性。 用法 将gamestate_integration_node.cfg安装到CS:GO cfg目录中。 示例: C:\Program Files (x86)\Steam\steamapps...Loading Game State Integration: gamestate_inte

    PrestigeModel:Prestige手游的Gamestate库,类似于纸牌游戏Splendor

    威望模型手机游戏的 Gamestate 库(目前处于),类似于纸牌游戏 Splendor作者由带给您,由 Rafał Tułaza(模型)和 Bartosz Stokrocki(机器人)编写。内容模型目录包含游戏模型的源代码和单元测试。 Arena目录...

    CSGO-Discord-rich-presence:从《不和谐》中的《反恐精英全球攻势》中显示当前游戏状态

    CS:GO不和谐的存在特色这是100%VAC安全,它使用 。 在Discord中显示来自CS...Linux 从下载适用于linux的最新版本和gamestate_integration_discord.cfg文件将gamestate_integration_discord.cfg文件移动到cfgs文件夹

    C#游戏编程GameClasses

    4. ** GameTimer.cs **: `GameTimer`是游戏循环中的重要组成部分,它负责处理时间相关的事件。游戏中的计时器通常用于更新游戏逻辑,比如动画的帧率控制、敌人行为的调度、玩家生命值的减少等。此类通常会有一个回...

    J2ME手机游戏设计案例源代码-GameEngine_TiledLayer

    ### J2ME手机游戏设计案例源代码-GameEngine_TiledLayer #### 概述 本案例提供了一套基于Java ME平台(J2ME)的游戏开发框架,重点在于如何使用`TiledLayer`类来构建游戏场景,并通过具体示例代码演示了游戏引擎的...

    pico-boots:PICO-8的基于Gamestate的框架

    皮靴 这是的基于游戏状态的框架。 它包括: 可以用作单独库的模块集合 一些课程可帮助您将游戏作为FSM的一部分运行 作为和等项目的一部分,它正在积极开发中。 该旨在演示框架的功能和API。 完整的构建管道仅适用...

    憎恶:游戏的憎恶就像地牢爬行者一样无赖

    在include / Game / GameState.hpp中编码您的游戏。 选修的: 将所有新状态添加到include / StateManager / States.hpp中。 按照与GameState.hpp或MenuState.hpp相同的模式创建新状态。 将新状态添加到srcs / ...

    TicTacToe:实现MiniMax的UI应用程序

    井字游戏 这是一个基于UI的井字游戏,您可以与AI进行对战... 这是一个多类程序,因此您需要下载所有类:GameAI,GameState,Log,MiniMax和TicTacToe。 要玩游戏,请运行“ TicTacToe”类,因为它是包含“ main”的类。

Global site tag (gtag.js) - Google Analytics