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?
11 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!!!!
@Normcore Assistant If you have interpolation set on a realtimetransform with a rigidbody when you do SnapTo, it seems to still interpolate between the old position and new one. How do I avoid this?
Let me check the knowledge base for you again. One moment! :books:
----------------------
The knowledge sources confirm that the
I'm sorry, but the knowledge sources do not explicitly state how to guarantee that interpolation is skipped when using
SnapTo() method on RealtimeTransform is intended to instantly move an object to a new position, bypassing interpolation. However, they do not provide explicit details about how interpolation is handled in Rigidbody mode or if there are additional steps required to guarantee that interpolation is skipped when using SnapTo() with a Rigidbody.
The documentation does mention a skipInterpolation property on the RealtimeTransformModel, but it does not specify if or how this is set automatically by SnapTo(), or if you need to set it manually in your use case RealtimeTransformModel Reference.
Summary:I'm sorry, but the knowledge sources do not explicitly state how to guarantee that interpolation is skipped when using
SnapTo() on a RealtimeTransform with a Rigidbody. If you are experiencing interpolation despite using SnapTo(), the documentation does not provide a documented method to force immediate snapping for Rigidbody objects beyond using SnapTo() itself. You may want to check if the skipInterpolation property can be set manually, but this is not covered in the provided documentation.
----------------------
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.
@Normcore Assistant what does "SetSafePosition" do?
Let me check the knowledge base for you again. One moment! :books:
----------------------
The
SetSafePosition method on the RealtimeTransformModel sets the position of the object while checking for NaN (Not a Number) values and using a custom epsilon for precision. This helps ensure that invalid or imprecise position values are not set on the model, which can help prevent synchronization issues or errors in the networked state RealtimeTransformModel Reference.
In summary:SetSafePosition safely sets the position, validating the input to avoid problematic values.
----------------------
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.
@Normcore Assistant how would you recommend "teleporting" a realtimetransform rigidbody safely from one spot to another without collisions with players in between?
Let me check the knowledge base for you again. One moment! :books:
----------------------
To safely "teleport" a
If you have interpolation enabled and still observe interpolation after calling
Use
RealtimeTransform with a Rigidbody from one spot to another—without causing collisions with players or objects in between—the recommended approach in Normcore is to use the SnapTo() method on the RealtimeTransform component. This method is designed to instantly move the object to a new position, bypassing interpolation and avoiding the simulation of movement through the space between the old and new positions, which would otherwise cause unwanted collisions RealtimeTransform Extra Notes.
Example:
Important notes:
- Ensure that your client owns the RealtimeTransform before calling SnapTo().
- Do not reparent or add/remove Rigidbody components at runtime, as this is not supported and can cause issues.
- If you need to also set rotation or scale, use the appropriate overloads of SnapTo().
Limitation:If you have interpolation enabled and still observe interpolation after calling
SnapTo(), the documentation does not provide a guaranteed way to force a true instant snap for Rigidbody objects beyond using SnapTo(). There is mention of a skipInterpolation property on the model, but the docs do not specify how or if you should set this manually RealtimeTransformModel Reference. If SnapTo() alone does not suffice, further investigation or support from NormalVR may be required.
Summary:Use
RealtimeTransform.SnapTo() to teleport Rigidbody objects and avoid collisions during the teleport. This is the documented and supported method in Normcore for this use case.
----------------------
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.