Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        moveable?.MoveForward(Input.GetAxis("Vertical"));// if the character implements the Imovable interface it can move using the axes called Vertical and Horizontal
        moveable?.MoveRight(Input.GetAxis("Horizontal"));

        if (Input.GetButtonDown("Jump"))// if the character implements the Ijumpable interface, it can jump
        {
            jumpable?.Jump();
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (character is IMovable) // if the character implements the Imovable interface it can move using the axes called Vertical and Horizontal
        {
            IMovable moveable = character as IMovable;
            moveable.MoveForward(Input.GetAxis("Vertical"));
            moveable.MoveRight(Input.GetAxis("Horizontal"));
        }
        if (character is IJumpable) // if the character implements the Ijumpable interface, it can jump
        {
            IJumpable jumpable = character as IJumpable;

            if (Input.GetButtonDown("Jump"))
            {
                jumpable.Jump();
            }
        }
    }