How to avoid Rigidbody RealtimeTransform objects colliding with things upon "teleporting"
Basically, I have a local player that teleports their "weapons" back to their holsters on respawn. These weapons are realtime transforms with rigidbodies. On remote clients, this teleport is registered as an instant linear motion from the last position back to the holster, causing crazy collisions and physics issues to anything in their way on the way back. Is there a "teleport" functionality in realtime transform that helps prevent this?
3 Replies
Hi @rj. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, there is a built-in way to handle this scenario in Normcore: you should use the
Use
SnapTo() method on the RealtimeTransform component. This method is specifically designed to instantly move (teleport) an object to a new position without interpolating or causing unwanted physics interactions that would occur if the position was simply set and synchronized over the network.
Here’s how you can use it:
This approach ensures that the teleportation is handled as an instant position update, preventing the "crazy collisions" and physics issues you described. Just make sure the client performing the snap owns the RealtimeTransform at the time of the call. This is the recommended way to reset or teleport objects in Normcore without causing interpolation or physics artifacts on remote clients RealtimeTransform Extra Notes.
If your weapons also need to reset their rotation or scale, you can use the overloads of SnapTo() that accept those parameters as well.
Note: If the object has a Rigidbody, ensure you are not reparenting or adding/removing Rigidbody components at runtime, as this is not supported and can cause further issues RealtimeTransform Extra Notes.
In summary:Use
RealtimeTransform.SnapTo() to teleport Rigidbody objects and avoid unwanted collisions or interpolation artifacts.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@446432643115122688> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
ahhhh perfect I knew there had to be something, thank you!!!!