无法从客户端发送命令,但可以从主机发送。 UNET

时间:2017-12-08 17:42:51

标签: c# unity3d multiplayer

帮助,我已经在Unity 3D中制作了2个模型,并且我编写了它,以便您可以选择您想要的模型,现在在主机上它完美运行,如果客户选择第一个模型,主机看到的是客户端播放器具有第一个模型,因此第二个模型。但是在客户端,事情并没有那么好,两种模型都没有出现,我认为这与命令有关。这是我的代码:

void Start() {

    if (GameObject.FindObjectOfType<ButtonScript>().Buttonn)
    {
        IsEye = true;

    }
    mybody = gameObject.GetComponent<Rigidbody>();
    OldSpeed = Speed;
    FirstPersoncamera.sensitivity = CameraMoveSpeed;
    FirstPersoncamera.smoothing = CameraSensitivity;
    if (!GameObject.FindObjectOfType<BeSinci1>().Buttonn)
    {
        IsEye = false;

    }

    if (IsEye && isLocalPlayer) {

        CmdSetEyeParent();
    }
    if (!IsEye && isLocalPlayer)
    {
        CmdSetRobotParent();

    }
}
[Command]
public void CmdSetEyeParent() {
    RobotParent.SetActive(false);
    EyeParent.SetActive(true);
    gameObject.GetComponent<BoxCollider>().center = new Vector3(0, 2.99f, 0.06880748f);
    gameObject.GetComponent<BoxCollider>().size = new Vector3(6.42f, 9.2f, 5.52f);
    anim = EyeParent.GetComponent<Animator>();
}
[Command]
public void CmdSetRobotParent() {
    RobotParent.SetActive(true);
    EyeParent.SetActive(false);
    gameObject.GetComponent<BoxCollider>().center = new Vector3(0, 0.1912432f, 0.06880748f);
    gameObject.GetComponent<BoxCollider>().size = new Vector3(0.812993f, 3.379633f, 1.02866f);
    //anim = EyeParent.GetComponent<Animator>();
}

如果您需要更多信息,请告诉我!我正在使用C#
谢谢!

0 个答案:

没有答案