Meldewesen following player
This commit is contained in:
parent
88e184e52d
commit
5c212f3560
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user