I’m using raycasts to determine collisions for my bullets. Sometimes the raycast misses the enemy, particularly when the enemy is moving towards the player, as shown in the video below.
Am I doing it wrong or is this an engine bug? Maybe a workaround I can use or something else?
Minimum repro case attached below as well.
Thanks
raycast-miss.zip (4.3 KB)
1 Like
The raycast won’t report a hit if it starts within a shape, which might be part of the problem.
Also how long are your ray casts? You can perhaps render the raycasts as well, using the “draw_line” message, to further help the debugging.
The raycast is very short so I assume what’s happening is the enemy is moved past the start point of the raycast and therefore misses.
I guess I could make the raycast longer and use the returned distance value somehow.
Thanks for the help.
Yeah, I that would be my first test.
I don’t recall the reason why the raycast won’t register if it is inside a shape (e.g. if it’s our code or the physics engine that decides that). It’s something I think we should look into. E.g. at the very least we could perhaps introduce a flag to include initial overlaps as well.
3 Likes