Beispiel #1
0
 public void TriggerInput(IO.DirectionTypes dir)
 {
     if (DriverType == DriveType.Driven)
     {
         move.MoveCommand(dir, speed);
     }
     else
     {
         Debug.LogWarning("Unable to call TriggerInput because Input is not being driven.");
     }
 }
Beispiel #2
0
    public void MoveCommand(IO.DirectionTypes dir, float speed)
    {
        if (dir == IO.DirectionTypes.UP)
        {
            vely += speed;
        }
        if (dir == IO.DirectionTypes.DOWN)
        {
            vely -= speed;
        }
        if (dir == IO.DirectionTypes.LEFT)
        {
            velx -= speed;
        }
        if (dir == IO.DirectionTypes.RIGHT)
        {
            velx += speed;
        }

        if (velx >= speedLimit)
        {
            velx = speedLimit;
        }
        if (velx <= -speedLimit)
        {
            velx = -speedLimit;
        }
        if (vely >= speedLimit)
        {
            vely = speedLimit;
        }
        if (vely <= -speedLimit)
        {
            vely = -speedLimit;
        }
    }