The Cool Trick Game Developers Use to Make Enemy AI See You. #Shorts



▶︎ ** RAYCAST GODOT 4 FREE TUTORIAL ** :

▶︎ ** BECOME AN INDEPENDENT GAMEDEV ** :

🎓 ** FREE APP “Learn GDScript From Zero” ** :

🎮 ** FREE INTERACTIVE GODOT TOUR ** –

🗨 ** DISCORD INVITE ** :
🗨 ** FOLLOW NATHAN ** :

——————————————
🖋 ** SYNOPSIS **
Raycasts and how enemies detect you in games.

#gamedev #gamengine #godot #games

——————————————-
** CC-BY 4.0 LICENSE **
Terms:
Attribute To: “CC-By 4.0 – GDQuest and contributors –

source

40 Comments

  1. Saw a recent video on an improved faster Raycast API added to Godot. So now this is even faster and easier for small devs to implement without worrying about optimzation as much.

  2. i’m gen stupid why did i never think to just have a rotating line that only detects the player if it’s not touching an obstacle instead of what i do where i have a small line that moves towards the player until it hits the player or an obstacle in my games

  3. And once the player is detected, the enemy is rotated accordingly to keep facing the player till breaks line of sight bt going behind a cover.

  4. Simple vector maths and Dot products can be used to optimise this by first checking if the player is even within field of view before doing raycasts. I made a video that would help explaining this kind of thing.

  5. Тут важно добавить что бы нпс начинал считать скорость и направление, когда теряет вас из поля видимости и вел туда курсор, так будет реалистичнее и будет вероятность его обмануть, 😊

  6. Original splinter cell used ray cast over each bone of player model and also analyzed pixel colors of body parts to understand how well it lit. This is how AI looked smarter than in many other (modern) stealth games, because they can spot leg or arm or heat outside of shadows or cover if it wasn't dark enough.

  7. I set up an AESA. Scanning cones that have a fixed azimuth and width depending on an enemy type. Dumb trash mobs get rays, humanoids get cones, humans and intelligent mobs get simulated radar that scans up and down and side to side within a detection region.

    The nice thing about ARPGs versus Wargaming is I don't need to simulate environmental and electronic warfare and RCS against a target

  8. Yeah but it goes further with ghost Rays that goes truthe the wall for a time to make Intelligent Based decision when the Player is behind an obstical the neural System knows it for a few secones to Name it Ai is also false the Most are title they so but the are an abstract Version

  9. I have been thinking all the time, is there a way to get an unlimited reach ray cast node in Godot or I just scale the node and that is it? And wouldn't scaling the ray cast node effect performance? (I'm asking for both 2D and 3D screens)

  10. you could:

    1. Use this ray technique

    2. Add AI memory with a 2-3 second threshold where the AI remembers the player's last seen position. When the ray loses contact, the AI heads toward that location while scanning, so it doesn't instantly forget the player.

    3. Optimize performance by only casting rays when the player is within a certain distance from the AI. Also cast rays at intervals like every 0.5 seconds instead of every frame. This needs the memory system from point 2 to work properly and keep the AI behavior smooth between casts.

    4. Add an engagement delay for more natural behavior: the AI needs either 1 second of continuous visibility to start engaging, OR if it's already in memory mode (seen the player once and searching during the threshold), just briefly seeing the player again is enough to trigger engagement. This gives a more human-like feel where you'd immediately react if you catch another glimpse of someone you're already looking for.

  11. Wouldn't it be more accurate to define a cone in front of the AI (single 4D vector) and just test if the player's box is inside? The ray has to be cast every frame anyway, and blocking objects could be grouped/tagged for poling.

Leave a Reply

Your email address will not be published. Required fields are marked *

You might like

© 2026 Cantinho do Vídeo - WordPress Video Theme by WPEnjoy