我使用Survival Shooter的统一资产构建了一个游戏。我面临的问题是摄像机只跟随主机设备中的主机播放器,而其他客户端设备中没有跟随任何播放器。
相机跟踪
public class LocalPlayerSetup : NetworkBehaviour
{
void Start()
{
GameObject.FindGameObjectWithTag ("EnemyManager").SetActiveRecursively (true);
if (isLocalPlayer) {
GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<CameraFollow> ().enabled = true;
GetComponent<PlayerMovement> ().enabled = true;
GetComponentInChildren<PlayerShooting> ().enabled = true;
}
}
LocalPlayerSetup脚本
private void Form_Customers_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'stage2DataSet.customers' table. You can move, or remove it, as needed.
/* this.customersTableAdapter.Fill(this.stage2DataSet.customers); */
this.customersTableAdapter.FillBy_Top_1000(this.stage2DataSet.customers);
}
答案 0 :(得分:1)
请勿在其“开始”方法中为摄像机指定目标。而是将其公开并将其分配给本地播放器的start方法,如下所示:
if (isLocalPlayer) {
("MainCamera").GetComponent<CameraFollow> ().target = transform;
}