Alright, I give up: How do you make a line of sight for an NPC?

After an entire day of nothing but tireless work [and a quick jog], I’ve given up, I don’t know how to make a line of sight for an NPC, which sucks because I could have sworn I had a personal bundle for that…
So, now I ask the forums.
My NPC’s in-game need to be able to see to a certain distance, and not behind them, at all. This way, you can sneak attack them at close range without being noticed. But, if you are noticed, they will spawn a sprite that alerts all other enemies in the surrounding area. So, I know it has to have something to do with extracting the player’s position, or walking into the range of an object. Whatever it is, it needs to work. And sadly no, I can’t leave a link to the game, but if you need me to explain more on what I’m asking, please do say so. I’ve been working on this for the past 10 hours so yeah I’m a bit done with trying lol

  1. RayCast : Emits a line of any length or direction if the line hits the player it could trigger whatever you need.
  2. Attach ( using an attacher) a partly transparent cone shaped object if the player has a collision with the thing, trigger what you need. ( you could also emit little circles that if the player gets in the proximity of trigger the thing.

Raycast should work, I feel like an idiot now lol.
But for future reference, Attached Objects don’t have collision triggers.
Thanks btw!

Oh thanks for that had no idea.
Glad to see I helped!

@browngr Dont worry I only figured out what raycasting was like 2 months ago lol

@browngr make sure you have two raycasts and a timer difference:
The first raycast should test for all objects, such as walls, and stops the enemy from seeing unless:
The second raycast has seen the player only(or a target) to attack.

@meburningslime I know, I know lol

When I find something I’m good at that others aren’t:
https://www.youtube.com/watch?v=xNWEEelhEQ0

Having that I knew to do that, I’m pretty sure that’s irrelevant lol

And also, pretty unhealthy way to go about things but I can’t make you change the way you live so you do you

Can’t play around, on the phone.
Just wondering, could you use the hit box of an invisible object?
I mean, then you could even define the shape? Like a radar cone?

Have to try once I get home :slight_smile:

Maybe, if you place loads of raycasts and set their angles, then have them all go into one output.