mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
修复主从交互bug
This commit is contained in:
@@ -14,6 +14,9 @@ namespace Game.JNGFrame.View.Entity
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player => App.Resource.Player;
|
||||
public CinemachineFreeLook FreeLook => App.Resource.FreeLook;
|
||||
|
||||
//本地玩家 视图
|
||||
private GameObject LocalView;
|
||||
|
||||
public VDPlayers(SViewSystem root) : base(root)
|
||||
{
|
||||
@@ -67,9 +70,20 @@ namespace Game.JNGFrame.View.Entity
|
||||
|
||||
public override GameObject NewView(EDPlayerData data)
|
||||
{
|
||||
var gameObject = Object.Instantiate(Player, VWorld.transform);
|
||||
gameObject.name = $"Player_{data.Id}";
|
||||
return gameObject;
|
||||
GameObject view;
|
||||
//如果这个角色是自己 则 直接拿自己的 View
|
||||
if (App.IsClient() && data.Value.Auth == App.ClientID)
|
||||
{
|
||||
if (LocalView is null) LocalView = Object.Instantiate(Player, VWorld.transform);
|
||||
view = LocalView;
|
||||
}
|
||||
else
|
||||
{
|
||||
view = Object.Instantiate(Player, VWorld.transform);
|
||||
}
|
||||
|
||||
view.name = $"Player_{data.Id}";
|
||||
return view;
|
||||
}
|
||||
|
||||
public override EDPlayerData[] GetData()
|
||||
@@ -80,7 +94,10 @@ namespace Game.JNGFrame.View.Entity
|
||||
public override void ViewRemove(GameObject view)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
Object.Destroy(view);
|
||||
if (LocalView != view)
|
||||
{
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user