Exemplo n.º 1
0
    private void handleMovement(float xspeed)
    {
        //0.2 instead 0 because character would run
        //falling animation on the uneven surfaces
        if (PlayerRigidBody.velocity.y < -4.5)
        {
            CharacterAnimator.SetBool("land", true);
        }
        if (!Attack && !Shoot && !Dodge)
        {
            PlayerRigidBody.velocity = new Vector2(runSpeed * movingDirection, PlayerRigidBody.velocity.y);
        }
        if (Jump && OnGround)
        {
            PlayerRigidBody.AddForce(new Vector2(0, jumpForce));
        }

        CharacterAnimator.SetFloat("speed", Mathf.Abs(movingDirection));
    }
Exemplo n.º 2
0
    // Movement Function
    private void movementHandler(float horizontal)
    {
        if (this.inScene == true)
        {
            if (PlayerRigidBody.velocity.y < 0)
            {
                playerAnimator.SetBool("land", true);
            }

            if (onGround)
            {
                PlayerRigidBody.velocity = new Vector2(horizontal * speed, PlayerRigidBody.velocity.y);       // x-axis movement
            }

            if (Jump && PlayerRigidBody.velocity.y == 0)
            {
                PlayerRigidBody.AddForce(new Vector2(0, jumpForce));         // Jumping Condition
            }
        }
    }
Exemplo n.º 3
0
 public override void Interact()
 {
     PlayerRigidBody.velocity = Vector2.zero;
     PlayerRigidBody.AddForce(new Vector2(0, JumpForce));
 }