Raycast keeps hitting even changing its origin

Hey all, I have a raycast on this playground but Im not able to make it stop hitting, the way I coded that (look to the Physics class) the ray position should get updated when I move my mesh, but for some reason it just don’t work.

When I update my mesh position the hit keeps happening, does anyone know why this is happening?

I tried to do the same steps on this other playground without success.

The way that I’m testing it is just move the mesh with the debugger, even the Ray debugger gets the new position, but the hit keeps hitting no matter what I do with the mesh position:

the ray position should get updated when I move my mesh , but for some reason it just don’t work

What do you mean by this? In your video, when you move the mesh, the ray position does move. It is the vertical line below your player mesh, and it is moving with the mesh. So that indicates the ray position is updating, as expected.

When I update my mesh position the hit keeps happening, does anyone know why this is happening?

When you move your mesh, you are also moving your ray. So your ray cast is always from the same position relative to your mesh, so it always hits the same point on the mesh.

Can you maybe explain a bit more what you are trying to do?

1 Like

Maybe Im doing something wrong so, I was trying to make my Ray to hit the ground and I expected that when I move my mesh far from the ground the hit would stop.

Is my Ray hitting the actual mesh and not the ground? :disappointed_relieved:

I didn’t considered that if thats the case…

EDIT: just tested it here and even after move the mesh the pickedMesh still the CubePrimitieve, the one from the ground and thats the issue, I move the mesh with the Ray, but it keeps hitting the ground just like I didn’t move it at all :frowning:

The ray is hitting your player mesh as well as the cube primitives attached as children to said mesh. If you, in the inspector, hide your player mesh and the cube primitives, you correctly hit the ground/cube 006.

1 Like