Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Start()
- {
- checkpoints = GetComponentsInChildren<Checkpoint>();
- sw.Start(); //stopwatch starts
- Load();
- checkpointsReached = 1;
- nextCheckpoint = checkpoints[checkpointsReached];
- }
- internal void CheckpointReached(Checkpoint checkpoint)
- {
- if (nextCheckpoint != checkpoint)
- return;
- checkpointsReached++;
- if (checkpoint.isFinish)
- {
- sw.Stop(); //stopwatch stops after reaching Finish
- EndRace();
- return;
- }
- if (checkpointsReached == checkpoints.Length)
- {
- checkpointsReached = 0;
- }
- nextCheckpoint = checkpoints[checkpointsReached];
- }
- void FixedUpdate()
- {
- Rigidbody2D rb = GetComponent<Rigidbody2D>();
- rb.AddForce(transform.up * speedForce); //acceleration
- //turning and stuff
- rb.angularVelocity = Input.GetAxis("Horizontal") * torqueForce;
- rb.velocity = ForwardVelocity() + RightVelocity() * driftFactor;
Add Comment
Please, Sign In to add comment