I’m currently doing a ground detection by using Raycast, i’l trying to see if a part is touching the ground.
I’m raycasting every frame in a HeartBeat function.
However i’m running in an issue where my part detect the ground sometimes faster or sometimes slower. I would like my ray to be all the times perfect so that the position of the detection is always at the same times however it’s not the case. When i’m putting my part in the sky and waiting for it to touch the ground, the ray isn’t always detecting the ground at the same position/time. That’s a problem for me however idk how i could fix that so if you hafve any ideas it would be cool !
Can’t reproduce, can you provide us a snippet of where you’re firing the ray to see what’s happening? Probably you’re performing a yielding action before raycasting as the above post said.
So here it’s what i’m doing basically however when i play and wait to touch the ground when i check the position of the part it’s not always the same Y position when i just replay the game. And that’s shouldn’t be normal because the ground should always be on the same y position.
Can you provide a video or place to reproduce what you’re experimenting? Everything seems fine with your code.
Do not let yourself be misinformed, please check how RunService actually works. Heartbeat can run in server and client.
RenderStepped should only be used for actions that really need to be performed before the frame renders, it needs to be carefully used for this kind of stuff to avoid having to deal with performance issues.
RayCast.rbxl (35.2 KB)
Here the place
In it you can see the part falling and it should print the position of the Part when it touch the ground but it’s never the same when you test multiple time