UE4中GameInstance和GameState区别

1.

Game State:

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.

Games Instance:

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 ;] I not sure if that class is replicated

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

点击打开链接https://answers.unrealengine.com/questions/189120/whats-the-deferent-between-gamestate-and-game-inst.html


2.

Games Instance:

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!

API documentation: UGameInstance

Game State:

The GameState is responsible for monitoring the state of the game on the client.

Conceptually, think of the GameState as the state of the game. It can keep track of properties like score, list of connected players, number of caps in a CTF game, where the pieces are in a chess game, what missions you have completed in an open world game, etc. In general, the GameState should track properties that change during gameplay. The GameState exists on the server and all clients and can replicate freely to keep all machines up to date.

点击打开链接https://answers.unrealengine.com/questions/259371/game-instance-and-game-state-difference.html


Games Instance:
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值