Raycast issues ...

On my vehicle I’m trying to do a simple cast to ground to retrieve the surface type.

it is working, and reports back the surface type.

I am just casting -90 in the Z. So it should be right under me.

But sometimes it casts all the way back to world 0,0,0. Then it goes back to underneath me, then back to world 0,0,0.

Also sometimes I get a green raycast line. Mostly it’s just red.

Been searching but I can’t find anything that points out the problem. I am triggering it with vehicle movement. (W or S).

Do I need to do more than just getworldlocation?


I’ll also note that I am doing an ‘endless runner’ with randomly spawning tiles.

When I cross over the border of the tiles (each in it’s own BP) it seems to cast to the default scene root for that BP.

When you specify the end location like that, you’re essentially telling it to do a trace towards the world location (40, 0, -90). This might be why it seems like the trace is being done towards the origin.

Instead try getting the up vector, multiply it by -90.0 to get a vector of that length in the downward direction of your actor, and then add it to your actor (or mesh world location) location to get the location below your vehicle. I’m guessing using this as the end location should solve your issue.

Awesome Stormrage!

I had actually replaced world location with actor location and it was the same. I saw the up vector and thought something like this might work but had no idea how to implement it.

Works perfectly :slight_smile: