Skip to content

Commit

Permalink
Car stuck check should be physics tick agnostic (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
TitanNano authored Aug 23, 2024
1 parent 166e27e commit 7bb429d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Objects/Vehicles/Car.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var rng: RandomNumberGenerator

var ground_normal := Vector3.DOWN

var stuck := 0
var stuck := 0.0
var new := true
var last_transform := Transform3D.IDENTITY

Expand All @@ -40,16 +40,16 @@ func activate() -> void:
self._on_choose_target()


func _physics_process(_delta: float) -> void:
func _physics_process(delta: float) -> void:
if not self.target_nav_node:
return

if self.last_transform.origin.is_equal_approx(self.global_transform.origin):
self.stuck += 1
self.stuck += 1.0 * delta
else:
self.stuck = 0
self.stuck = 0.0

if self.stuck >= 5:
if self.stuck >= 5.0:
Logger.info("despawning stuck car")
self.queue_free()
debug_target.queue_free()
Expand Down

0 comments on commit 7bb429d

Please sign in to comment.