C# Unity3d isLocalPlayer问题
我在Unity中遇到了isLocalPlayer bool的问题。我有一个简单的移动脚本,如果isLocalPlayer,我想移动一个播放器。但是isLocalPlayer总是返回false。代码:C# Unity3d isLocalPlayer问题,c#,unity3d,game-engine,unity5,C#,Unity3d,Game Engine,Unity5,我在Unity中遇到了isLocalPlayer bool的问题。我有一个简单的移动脚本,如果isLocalPlayer,我想移动一个播放器。但是isLocalPlayer总是返回false。代码: using UnityEngine; using System.Collections; using UnityEngine.Networking; public class PlayerRotating : NetworkBehaviour { // Use this for init
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class PlayerRotating : NetworkBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
if(isLocalPlayer)
{
var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
}
}
}
我的玩家预制检查员:
你能告诉我哪里定义了
isLocalLayer
吗?对不起,我不明白你的问题。我没有在任何地方定义isLocalPlayer。这就是为什么它总是false
我不必在任何地方定义它,它是由Unity预定义的。您的脚本中是否有start.server()
或start.host()
?