Hello everyone! Hope you all had a happy new year!
I have a question around Raycast. I’m making a topdown game, and I’m working on a feature where the enemies (enemy_1) is moving towards the player (player_body). However if the enemies (enemy_1)'s vision is blocked by wall (WallCornerFrontRight), then enemy will be idle.
Hi,
maybe a very basic question first: do you have your WallCornerFrontRight-sprite in the scene? It looks quite different (bricks) from the walls you have in your screenshot (wooden planks).
I am not 100% sure about that but your second sub event for the raycast is probably not necessary. I guess the state of your object variable Alert is 0 by default anyway? So if the raycast does not detect anything it can just stay as it is.
The WallCornerFrontRight sprite is in the scene, I just duplicated 4 of them and stretched them to create a room to test
I disabled the second sub event of the raycast, but the enemies are still moving for some reason. BTW I’m using the Boids movement rather than the pathfinder, does that affect raycasting?
I just realized where the problem is. If you check the linked example project, it says in the comment that the player and the wall object are both members of a group (solid). That’s what you also need to do: put your player and the wall in a group and test the raycast against it.
I have no experience with the boids movement and the linked example only uses the move-actions (no pathfinding) but there should be no problem with the raycast in either case.
You are right I needed to put both the player object and solid together into a group for it to work Yay. And to confirm it works with boids too. Thanks again!