How to make player stop if he;'s in enemies line of sight?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KantateKid

Hi guys,

so i’m making game about scp 173 and I am wondering how to create mechanic that stops player from moving before enemy is blinking.

I think I should use Timer, and area2d as an enemy vision but I have no idea how to write script for this, I watched some youtube tutorials but I have no idea how to make player stop when he’s in enemy sight.

Does anyone have any ideas?

:bust_in_silhouette: Reply From: alexp

Your code for controlling the player character should have some kind of speed variable that’s multiplied with a direction vector that’s determined by inputs. Simply connect a function that sets the speed to 0, to the signal that activates when the player’s Area2D enters the Area2D for the visual field. You may have to experiment to see if

For blinking, you can change the visual field Area2D’s collision layer or mask, depending on which area’s signal you’re using: Physics introduction — Godot Engine (stable) documentation in English

Waiting for answer I was reading about raycasts and trying them, what do you think about this ? Will it be better?

by the way thank’s for your answer :smiley:

KantateKid | 2022-10-16 19:41