Public repository for MUR pre alpha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
769 B

  1. extends Spatial
  2. var road_ray:RayCast
  3. var collider
  4. var road:Road
  5. var road_index:int = 0
  6. puppet var slave_transform:Transform
  7. signal road_entered(road)
  8. func _ready():
  9. road_ray = get_node("ray")
  10. func _physics_process(delta):
  11. if is_network_master():
  12. if road_ray.is_colliding():
  13. if road_ray.get_collider() != collider:
  14. var parent = road_ray.get_collider().get_parent()
  15. if parent is Road && (road == null && road_index == parent.get_index() || road.get_index() == parent.get_index() - 1) && !parent.is_preview():
  16. collider = road_ray.get_collider()
  17. road = parent
  18. road_index = road.get_index()
  19. emit_signal("road_entered",road)
  20. rset_unreliable("slave_transform", get_global_transform())
  21. else:
  22. set_global_transform(slave_transform)