Beispiel #1
0
    void Move()
    {
        Vector3 moveVector = new Vector3(0, 0, 0);

        if (Input.GetKey(KeyCode.A))
        {
            moveVector = moveVector + new Vector3(-1, 0, 0);
            if (anim.gameObject.transform.localScale.x > 0)
            {
                anim.gameObject.transform.localScale = new Vector3(anim.gameObject.transform.localScale.x * -1, anim.gameObject.transform.localScale.y, anim.gameObject.transform.localScale.z);
            }
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveVector = moveVector + new Vector3(1, 0, 0);
            if (anim.gameObject.transform.localScale.x < 0)
            {
                anim.gameObject.transform.localScale = new Vector3(anim.gameObject.transform.localScale.x * -1, anim.gameObject.transform.localScale.y, anim.gameObject.transform.localScale.z);
            }
        }
        if (Input.GetKey(KeyCode.W))
        {
            moveVector = moveVector + new Vector3(0, 1, 0);
        }
        if (Input.GetKey(KeyCode.S))
        {
            moveVector = moveVector + new Vector3(0, -1, 0);
        }

        Vector3 pos = this.transform.position + (moveVector * speed * speedMod * shoot.GetSpeedMod() * Time.deltaTime);

        if (mc.CheckMove(pos))
        {
            if (moveVector == Vector3.zero)
            {
                reflection.SetBool("Walking", false);
            }
            else
            {
                reflection.SetBool("Walking", true);
            }
            direction = moveVector;
            this.transform.position = pos;
        }
    }