CarSitter.cs 725 B

12345678910111213141516171819202122232425262728
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace TrafficSimulation{
  5. public class CarSitter : MonoBehaviour
  6. {
  7. public CarPool carPool;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. }
  12. // Update is called once per frame
  13. void Update()
  14. {
  15. if(gameObject.activeInHierarchy){
  16. checkRotation();
  17. }
  18. }
  19. void checkRotation(){
  20. if(Vector3.Dot(gameObject.transform.up, Vector3.down) > 0.5){
  21. Debug.Log("despawn car, because its turtleing!");
  22. this.carPool.despawnCar(gameObject);
  23. }
  24. }
  25. }
  26. }