Exemplo n.º 1
0
    public void FixedUpdate()
    {
        caterpillar.ax = caterpillar.speed * VfigInput.GetAxis(caterpillar.playerNum - 1, VfigInput.Axis.LeftStickX);

        caterpillar.vx += caterpillar.ax * Time.fixedDeltaTime;
        caterpillar.vx *= caterpillar.friction;

        caterpillar.vy *= caterpillar.jumpArcFriction;

        jumpTimer -= Time.fixedDeltaTime;

        if (jumpTimer <= 0 || !VfigInput.GetButton(caterpillar.playerNum - 1, VfigInput.Button.A))
        {
            caterpillar.ChangeState(new WalkingState(caterpillar));
            return;
        }

        caterpillar.SideCollisionLeft();
        caterpillar.SideCollisionRight();

        if (caterpillar.vy < 0 && caterpillar.GroundCollision())
        {
            Debug.Log("ground or low vy");
            caterpillar.ChangeState(new WalkingState(caterpillar));
            return;
        }

        if (caterpillar.vy >= 0 && caterpillar.CollisionTop())
        {
            Debug.Log("Top collision");
            caterpillar.vy = 0;
            caterpillar.ChangeState(new WalkingState(caterpillar));
            return;
        }

        caterpillar.transform.Translate(caterpillar.vx * Time.deltaTime, caterpillar.vy * Time.deltaTime, 0);
    }
Exemplo n.º 2
0
 public bool GetButton(VfigInput.Button button)
 {
     return(VfigInput.GetButton((int)_gamepadAssignment, button));
 }