Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        velocity = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        if (velocity.magnitude > 1)
        {
            velocity.Normalize();
        }
        state.SetDirection();
        state.Update();

        // Attack
        if (Input.GetKey(attackKey) && releaseAttack)
        {
            releaseAttack = false;
            state.Attack();
        }
        else if (!Input.GetKey(attackKey))
        {
            releaseAttack = true;
        }

        // Interact
        if (Input.GetKey(interactKey) && releaseInteract)
        {
            releaseInteract = false;
            state.Interact();
        }
        else if (!Input.GetKey(interactKey))
        {
            releaseInteract = true;
        }
    }