Meldewesen following player

This commit is contained in:
incredibleLeitman 2019-12-27 20:50:38 +01:00
parent 88e184e52d
commit 5c212f3560
2 changed files with 10 additions and 8 deletions

View File

@ -22,10 +22,14 @@ func _ready():
func _process(_delta):
if current_target:
# stop following player if pill level is high enough and player is not in an illegal area
if current_target and Pills.get_round_level() > _player_follow_pill_level and _playerRef.Is_in_Illegal_Area() == false:
if Pills.get_round_level() > _player_follow_pill_level and _playerRef.Is_in_Illegal_Area() == false:
Logger.info("player pill level ok and no illegal actions detected!")
current_target = null
# otherwise set new position of player
else:
current_target = _playerRef.transform.origin
func _on_body_entered_visibility(body: PhysicsBody):
@ -38,9 +42,8 @@ func _on_body_entered_visibility(body: PhysicsBody):
if _playerRef.Is_in_Illegal_Area():
Logger.info("player is in illegal area - following!")
current_target = body.transform.origin
# If the player didn't take enough pills lately, they're suspicious -> Run towards them!
if Pills.get_round_level() <= _player_follow_pill_level:
elif Pills.get_round_level() <= _player_follow_pill_level:
Logger.info("The player's pill level is too low - following!")
current_target = body.transform.origin

View File

@ -45,8 +45,7 @@ func _process(delta):
var current_goal = body.current_target if body.current_target else _get_current_goal()
# Move towards the current goal
var direction: Vector3 = (current_goal - _get_body_position())
var direction_normalized: Vector3 = direction.normalized()
var direction_normalized: Vector3 = (current_goal - _get_body_position()).normalized()
body.look_towards(direction_normalized)
body.move_towards(direction_normalized * speed)