I am trying to make a horror game (top down), and I want to make it to where the killer only starts chasing the player once the player crosses it’s line of sight, of course there is walls and I don’t want the killer to see through the walls. I have tried to use ray casting but I can’t figure out how to get what I want out of it. If it helps, for the killer I am using the pathfinding behaviour, and using an object number variable for what “Mode” it is in (patrolling, chasing, etc.). So is there just something I’m missing with the ray casting, or do I have to do some tricks with collision? Any help is appreciated, thanks.
Can you post your raycast events?
Raycast sends a “ray” either at an angle/distance or between 2 points and tests for an object. If there’s an object like a wall it triggerers the action(s) and sets an optional x,y value to variables of the point of detection.
Unlike most conditions, inverting it doesn’t invert the condition, it switches it to detecting the farthest object instead of the nearest.
So, you can check between the player and enemy against an object or group like a wall and it will trigger if there’s a wall.
To trigger if there’s not a wall, you need to put the raycast condition into a NOT condition. This would trigger if there’s wasn’t an object detected.
You might need to put the raycast inside a for each object for your enemy objects or put a for each as a subevent. Each situation is unique depending on your desired actions.
I tried using the “Not” condition on the raycast and it worked perfectly. Thanks!