Guest User

Untitled

a guest
Feb 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. void Start()
  2. {
  3. checkpoints = GetComponentsInChildren<Checkpoint>();
  4. sw.Start(); //stopwatch starts
  5. Load();
  6. checkpointsReached = 1;
  7. nextCheckpoint = checkpoints[checkpointsReached];
  8. }
  9.  
  10. internal void CheckpointReached(Checkpoint checkpoint)
  11. {
  12. if (nextCheckpoint != checkpoint)
  13. return;
  14.  
  15. checkpointsReached++;
  16.  
  17. if (checkpoint.isFinish)
  18. {
  19. sw.Stop(); //stopwatch stops after reaching Finish
  20. EndRace();
  21. return;
  22. }
  23.  
  24. if (checkpointsReached == checkpoints.Length)
  25. {
  26. checkpointsReached = 0;
  27. }
  28.  
  29. nextCheckpoint = checkpoints[checkpointsReached];
  30. }
  31.  
  32. void FixedUpdate()
  33. {
  34. Rigidbody2D rb = GetComponent<Rigidbody2D>();
  35. rb.AddForce(transform.up * speedForce); //acceleration
  36.  
  37.  
  38. //turning and stuff
  39. rb.angularVelocity = Input.GetAxis("Horizontal") * torqueForce;
  40. rb.velocity = ForwardVelocity() + RightVelocity() * driftFactor;
Add Comment
Please, Sign In to add comment