|
I have an AI bot that I am trying to utilize raycasting with. For some reason, I cannot get it to work. Here is the code I am using:
Any help with this would be appreciated. Thanks.
(comments are locked)
|
|
You could be a bit more specific! What the code seems to lack is, it doesn't actually check if Physics.Raycast did hit something. Your code would look something like this (
also, if the origin (point of centre) of your bot is on the floor it would be useful to move the position of the ray a bit up (make it The layerMask you defined means you're only looking at objects in Layer 8, that's what you want I guess? If you want to test for objects in all layers just remove the "
(comments are locked)
|
|
use the debug.DrawRay to see if your ray really goes where you want and check if the collider of your other object has the correct size or not. also check if it's in layer 8 or not. it should not be in "ignore raycast" layer
(comments are locked)
|
|
Thanks so much. Yeah, I wasn't checking whether or not it hit something. Also, the problem was when my team modeled the bot, the axis got messed up so I needed to be casting the ray "down" instead of "forward" in order to actually cast it in the direction the bot was facing. Thanks :)
(comments are locked)
|
