Ejemplo n.º 1
0
 private bool Boost()
 {
     if (realAmount > 0 && car.getEngineEnable() && isBoosting)
     {
         direction           = colliders.GetHeadCollider().position - colliders.GetTailCollider().position;
         _rigidbody.velocity = Vector3.Lerp(_rigidbody.velocity, direction.normalized * POWER, TIME_TO_MAX * Time.deltaTime);
         realAmount         -= 1;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
    public int IsForward()
    {
        var Head = colliders.GetHeadCollider();
        var Tail = colliders.GetTailCollider();
        var x    = Mathf.Sign((Head.position.x - Tail.position.x));
        var z    = Mathf.Sign((Head.position.z - Tail.position.z));

        if (Mathf.Sign(_rigidbody.velocity.x) == x && Mathf.Sign(_rigidbody.velocity.z) == z)
        {
            // FORWARD
            return(1);
        }
        else if (Mathf.Abs(_rigidbody.velocity.x) <= 0.1f && Mathf.Abs(_rigidbody.velocity.z) <= 0.1f)
        {
            // NOT MOVING
            return(0);
        }
        else
        {
            // BACKWARD
            return(2);
        }
    }