Пример #1
0
 public void rotator()
 {
     angle = (me.eulerAngles.y);
     delta = C_MF.round(C_MF.toRotation(angle, direction * 90.0f), 2) / 90;
     if (Mathf.Abs(delta) < 0.1f)
     {
         me.rotation = Quaternion.Euler(0, direction * 90.0f, 0);
     }
     else
     {
         me.Rotate(0, delta * k_rotation * speed, 0);
     }
 }
Пример #2
0
    public void move()
    {
        float d      = direction % 4;
        float speedX = ((d == 0) || (d == 2)) ? (speed * k_speed * Mathf.Abs(Mathf.Cos(C_MF.G2R(angle)))) : 0;
        float speedY = ((d == 1) || (d == 3)) ? (speed * k_speed * Mathf.Abs(Mathf.Sin(C_MF.G2R(angle)))) : 0;

        Tank.GetComponent <Rigidbody>().velocity = new Vector3(speedX * (1 - d), 0, speedY * (d - 2));
    }