fx: rotation wrapping interaction bug
This commit is contained in:
parent
6432b709ef
commit
07f3c13fd2
|
|
@ -30,6 +30,7 @@ func _process(delta: float) -> void:
|
|||
# smoothly rotate
|
||||
if self.rotation != self.desired_rotation: # FIXME: causes the mirror sprites to flip out
|
||||
self.rotation = lerp_angle(self.rotation, self.desired_rotation, clampf(4 * delta, 0, 1))
|
||||
|
||||
# Boundary mirroring
|
||||
_handle_wrapping()
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ func become_injured() -> void:
|
|||
mirrorSprite3.play("Injured")
|
||||
|
||||
func _on_sight_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("predators") or (body.is_in_group("player") and health < maxHealth):
|
||||
if body.is_in_group("predators") or body.is_in_group("player"):
|
||||
fsm.transition_to_next_state(fsm.States.FLEEING, {"threat": body})
|
||||
|
||||
|
||||
|
|
@ -94,14 +95,11 @@ func _handle_wrapping():
|
|||
mirrorSprite3.visible = true
|
||||
|
||||
# Right
|
||||
#mirrorSprite1.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y)
|
||||
mirrorSprite1.position = Vector2(GameManager.screen_size.x, 0)
|
||||
mirrorSprite1.global_position = global_position + Vector2(GameManager.screen_size.x, 0)
|
||||
# Diag
|
||||
#mirrorSprite2.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y + GameManager.screen_size.y)
|
||||
mirrorSprite3.position = Vector2(GameManager.screen_size.x, GameManager.screen_size.y)
|
||||
mirrorSprite3.global_position = global_position + Vector2(GameManager.screen_size.x, GameManager.screen_size.y)
|
||||
# Bottom
|
||||
#mirrorSprite3.position = Vector2(sprite.position.x, sprite.position.y + GameManager.screen_size.y)
|
||||
mirrorSprite2.position = Vector2(0, GameManager.screen_size.y)
|
||||
mirrorSprite2.global_position = global_position + Vector2(0, GameManager.screen_size.y)
|
||||
|
||||
|
||||
elif position.x < GameManager.screen_size.x/2:
|
||||
|
|
@ -111,14 +109,11 @@ func _handle_wrapping():
|
|||
mirrorSprite3.visible = true
|
||||
|
||||
# Top
|
||||
#mirrorSprite1.position = Vector2(sprite.position.x, sprite.position.y - GameManager.screen_size.y)
|
||||
mirrorSprite1.position = Vector2(0, - GameManager.screen_size.y)
|
||||
mirrorSprite1.global_position = global_position + Vector2(0, - GameManager.screen_size.y)
|
||||
# Diag
|
||||
#mirrorSprite2.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y - GameManager.screen_size.y)
|
||||
mirrorSprite2.position = Vector2(GameManager.screen_size.x, - GameManager.screen_size.y)
|
||||
mirrorSprite2.global_position = global_position + Vector2(GameManager.screen_size.x, - GameManager.screen_size.y)
|
||||
# Right
|
||||
#mirrorSprite3.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y)
|
||||
mirrorSprite3.position = Vector2(GameManager.screen_size.x, 0)
|
||||
mirrorSprite3.global_position = global_position + Vector2(GameManager.screen_size.x, 0)
|
||||
|
||||
|
||||
elif position.y < GameManager.screen_size.y/2:
|
||||
|
|
@ -128,14 +123,11 @@ func _handle_wrapping():
|
|||
mirrorSprite3.visible = true
|
||||
|
||||
# Left
|
||||
#mirrorSprite1.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y)
|
||||
mirrorSprite1.position = Vector2(- GameManager.screen_size.x, 0)
|
||||
mirrorSprite1.global_position = global_position + Vector2(- GameManager.screen_size.x, 0)
|
||||
# Bottom
|
||||
#mirrorSprite2.position = Vector2(sprite.position.x, sprite.position.y + GameManager.screen_size.y)
|
||||
mirrorSprite2.position = Vector2(0, GameManager.screen_size.y)
|
||||
mirrorSprite2.global_position = global_position + Vector2(0, GameManager.screen_size.y)
|
||||
# Diag
|
||||
#mirrorSprite3.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y + GameManager.screen_size.y)
|
||||
mirrorSprite3.position = Vector2(- GameManager.screen_size.x, GameManager.screen_size.y)
|
||||
mirrorSprite3.global_position = global_position + Vector2(- GameManager.screen_size.x, GameManager.screen_size.y)
|
||||
|
||||
|
||||
else:
|
||||
|
|
@ -145,11 +137,8 @@ func _handle_wrapping():
|
|||
mirrorSprite3.visible = true
|
||||
|
||||
# Left
|
||||
#mirrorSprite1.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y)
|
||||
mirrorSprite1.position = Vector2(- GameManager.screen_size.x, 0)
|
||||
mirrorSprite1.global_position = global_position + Vector2(- GameManager.screen_size.x, 0)
|
||||
# Diag
|
||||
#mirrorSprite2.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y - GameManager.screen_size.y)
|
||||
mirrorSprite2.position = Vector2(- GameManager.screen_size.x, - GameManager.screen_size.y)
|
||||
mirrorSprite2.global_position = global_position + Vector2(- GameManager.screen_size.x, - GameManager.screen_size.y)
|
||||
# Top
|
||||
#mirrorSprite3.position = Vector2(sprite.position.x, sprite.position.y - GameManager.screen_size.y)
|
||||
mirrorSprite3.position = Vector2(0, - GameManager.screen_size.y)
|
||||
mirrorSprite3.global_position = global_position + Vector2(0, - GameManager.screen_size.y)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ func enter(previous_state_path: String, data := {}) -> void:
|
|||
threat = owner
|
||||
|
||||
func physics_update(_delta: float) -> void:
|
||||
if owner.position.distance_to(threat.position) > threshold:
|
||||
if owner.position.distance_to(threat.position) > threshold or threat == owner:
|
||||
finished.emit(owner.fsm.States.IDLE, {})
|
||||
return
|
||||
owner.move(flee_from(threat.position))
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@ func enter(previous_state_path: String, data := {}) -> void:
|
|||
timer.start((float)(randi() % 5)/5)
|
||||
|
||||
func physics_update(_delta: float) -> void:
|
||||
owner.move(_delta * dir)
|
||||
#owner.move(_delta * Vector3(randfn(0, 1), randfn(0, 1), 0))
|
||||
owner.move(_delta * Vector3(randfn(0, 1), randfn(0, 1), 0))
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if (randi() % 4 != 0):
|
||||
finished.emit(owner.fsm.States.IDLE, {})
|
||||
#finished.emit(owner.fsm.States.RANDOMMOVEMENT, {})
|
||||
finished.emit(owner.fsm.States.RANDOMMOVEMENT, {})
|
||||
else:
|
||||
finished.emit(owner.fsm.States.IDLE, {})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue