Hello folks, I’m making a top down shooter and need help making my AI. My AI is capable of following the player and shooting towards him but it is detecting the player through walls, shooting without considering the wall is blocking it and getting stuck between 2 walls, doing nothing when this happens.
How can i make the walls block raycast detection and the AI to only shoot when there are no walls between it and the player? Where the AI get’s stuck, the walls are impassable pathfinding obstacles.
The event with the action that creates the angryWisp’s flame is not a sub event of the check that the number of players > 0. It’s a child of a blank event, so it’ll get actioned whether or not the player was the first object the raycast hit.
Ha, I just spotted something - you’re raycasting from AngryWisp.X(), AngryWisp.X(). Change the last X() to a Y(). Fix that and see if that makes a difference.
Fixed this but the see through walls and the freezing persists. I don’t know if this helps but the wisp goes to a place I’ve been, pushes me out of it and stays there frozen.
Duh, I should have spotted it earlier again. You’re checking the raycast against a wall object, but checking is the player count > 0. You’ll need to check that wall count = 0. Number of players will always be greater than 0.
I’d suggest also that you put all the solid objects that the AngryWisp cannot see through into a group, and then raycast using that group. So the raycast will be on the group and not the wall object, and the check will be on number of group objects, and not wall objets. The big benefit of this is that more objects can be added without having to alter or add to your events.
I put them on a group as you said (player and wall) and it’s working perfeclty, the wisp isn’t seing through walls nor freezing and now it follows until the ray is broken. Thank you for the help man.