- Home /
Raycast to detect how high blocks are infront of object
Hello, I am working on a simple game with a simple AI. Right now I am having troubles with ray casting. I want the AI to be able to detect how high blocks are in front of him. For example if there are 2 blocks in front of him, I want him to be able to jump to only clear those two blocks. I just need help with ray casting so it is able to detect how high the blocks are in front of him (is there 2, 3, etc).
I can provide more info if needed. Thanks!
Without your code, I can just give you theory. One way is to do the Raycast() from the maximum height he can jump. So the the position of the Raycast() would be something like:
var raycastPos = transform.position + Vector3.up * maxHeight;
Answer by chris_taylor · Feb 28, 2014 at 07:01 PM
Raycast from the AI position in front to see if there is a block you need to jump over, if there is then ray cast from the max block height.
your raycasting will look like this
Your answer

Follow this Question
Related Questions
Linecast is always blocked. 2 Answers
Rotate with Raycast??? 2 Answers
Raycasting crashing Unity? 3 Answers