move player wrap to player script
This commit is contained in:
parent
d851d35cac
commit
c3e44a38ab
2 changed files with 7 additions and 4 deletions
|
|
@ -59,6 +59,13 @@ func get_movement_vector() -> Vector2:
|
|||
else: return Vector2(0, signf(y_strength))
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if wrapping:
|
||||
position.x = wrapf(position.x, x_min_wrap, x_max_wrap)
|
||||
position.y = wrapf(position.y, y_min_wrap, y_max_wrap)
|
||||
reset_physics_interpolation()
|
||||
|
||||
|
||||
func _on_loop_toggled(enabled: bool, loop_size: Rect2i) -> void:
|
||||
if enabled:
|
||||
x_min_wrap = loop_size.position.x
|
||||
|
|
|
|||
|
|
@ -13,10 +13,6 @@ func _state_physics_update(_delta: float) -> void:
|
|||
player.velocity = direction * player.max_speed * player.speed_mult
|
||||
|
||||
player.move_and_slide()
|
||||
|
||||
if player.wrapping:
|
||||
player.position.x = wrapf(player.position.x, player.x_min_wrap, player.x_max_wrap)
|
||||
player.position.y = wrapf(player.position.y, player.y_min_wrap, player.y_max_wrap)
|
||||
#endregion
|
||||
|
||||
if watch_state([WALKING]): return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue