Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        if (myShoot == null)
        {
            myShoot = this.GetComponent <shoot>();
            if (myShoot == null)
            {
                Debug.Log("myShoot in controlls is null!");
                return;
            }
        }
        if (myMovement == null)
        {
            myMovement = this.GetComponent <movement>();
            if (myMovement == null)
            {
                Debug.Log("myMovement in controlls is null!");
                return;
            }
        }

        if (Input.GetAxis("Horizontal") > 0)
        {
            myMovement.right();
        }
        else if (Input.GetAxis("Horizontal") < 0)
        {
            myMovement.left();
        }

        if (Input.GetAxis("Vertical") > 0)
        {
            myMovement.forward();
        }
        else if (Input.GetAxis("Vertical") < 0)
        {
            myMovement.backward();
        }

        if (Input.GetButtonDown("Fire1"))
        {
            //Debug.Log("Peng Peng");
            myShoot.CmdFire();
        }
    }