How to get an accurate position/CFrame of an unanchored, moving part?

The issue:
To make this as short as possible, I’m just simply trying to script a grapplehook. When the hook is fired, I use a VectorForce to make the hook move through the air. Then, when the hook touches a part, a touched event would fire, and the hook would become anchored. Well, the position of the hook when it is anchored is far different from the position it was when it touched the part, unanchored (e.g., the hook would be 10-20 studs off, sometimes far away from the part it touched). Neither axes were even close to what it was unanchored. I’ve tried saving an old position and then using the old position to correct the hook’s position, but that didn’t work…

What I’m looking for:
My goal is to correct the position of the hook so that it is seated properly on the part. I simply want to know if there is a way I can get the correct position of the hook when it had touched the part.

I’d appreciate any help given. ^-^

.Touched events are rather innacurate. You could opt to using raycasting, by making the hook’s cancollide property false and raycasting from a saved position of the hook, wait maybe 0.2 seconds, and raycast to the new position of the hook and see if any part was detected, and anchor the hook unto the raycast hit position.

I feel kind’ve stupid for not thinking of raycasting. :joy: Thanks for the tip; I just tried it out and it works much better!

According to online searches, you should be using BasePart:GetRenderCFrame() to get the actual interpolation. Though, this property is unused now, and you should probably stop using .Touched because they are very inaccurate when replicating. If you are to use them, you should make it all on the client or all on the server.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.