示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetAxisRaw("Vertical") == 1)
        {
            racerScript.Accelerate();
        }
        else
        {
            racerScript.Deaccelerate();
        }

        if (Input.GetAxisRaw("Vertical") == -1)
        {
            racerScript.Deaccelerate();
        }

        if (Input.GetAxisRaw("Horizontal") == 1)
        {
            racerScript.TurnRight();
        }
        else if (Input.GetAxisRaw("Horizontal") == -1)
        {
            racerScript.TurnLeft();
        }
    }
示例#2
0
 void Move()
 {
     if (Vector3.Distance(transform.position, nextSubWayPoint) > 1f)
     {
         racerScript.Accelerate();
     }
     else
     {
         racerScript.DeaccelerateUntil(.25f);
     }
     racerScript.TurnTowards(nextSubWayPoint);
     if (Vector3.Distance(transform.position, nextSubWayPoint) <= 0.25f)
     {
         nextWayPoint    = nextWayPoint.nextWayPoint;
         nextSubWayPoint = GetRandomSubWayPoint(nextWayPoint);
     }
 }