Skip to content

Commit

Permalink
Toggle collisions properly when Flying is set in a script.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsrw committed Nov 26, 2023
1 parent 98edda7 commit e463afd
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/nodes/player_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ gdobj PlayerNode of KinematicBody:
state.local_flags.watch:
if MouseCaptured.removed:
self.skip_next_mouse_move = true
elif change.item == Flying:
for i in [0, 1, 2]:
let collision_enabled = Flying.removed
self.set_collision_mask_bit(i, collision_enabled)

state.global_flags.watch:
if LoadingLevel.added:
Expand Down Expand Up @@ -294,14 +298,9 @@ gdobj PlayerNode of KinematicBody:
time = get_mono_time()
toggle = ?self.jump_time and time < self.jump_time.get + fly_toggle

if toggle:
if toggle and Playing notin state.local_flags:
self.jump_time = nil_time
if Playing in state.local_flags:
self.flying(false)
else:
self.flying(not self.flying)
for i in [0, 1, 2]:
self.set_collision_mask_bit(i, not self.flying)
self.flying(not self.flying)
elif self.is_on_floor():
self.velocity += vec3(0, jump_impulse, 0)
self.jump_time = some time
Expand Down

0 comments on commit e463afd

Please sign in to comment.