Waypoint.cs 949 B

1234567891011121314151617181920212223242526272829303132
  1. // Traffic Simulation
  2. // https://github.com/mchrbn/unity-traffic-simulation
  3. using UnityEngine;
  4. namespace TrafficSimulation {
  5. public class Waypoint : MonoBehaviour {
  6. [HideInInspector] public Segment segment;
  7. public void Refresh(int _newId, Segment _newSegment) {
  8. segment = _newSegment;
  9. name = "Waypoint-" + _newId;
  10. tag = "Waypoint";
  11. //Set the layer to Default
  12. gameObject.layer = 0;
  13. //Remove the Collider cause it it not necessary any more
  14. RemoveCollider();
  15. }
  16. public void RemoveCollider() {
  17. if (GetComponent<SphereCollider>()) {
  18. DestroyImmediate(gameObject.GetComponent<SphereCollider>());
  19. }
  20. }
  21. public Vector3 GetVisualPos() {
  22. return transform.position + new Vector3(0, 0.5f, 0);
  23. }
  24. }
  25. }