cryptomax
cryptomax2w ago

Childing Realtime Transform Behavior

If I realtime instantiate an object and then parent it to another object. obviously that parenting only exists on the clients system who instantiated. If they are the realtime owner though will their transform continue to properly sync in world space correctly the world position of the child obejct for other connected players? So even though we aren't parenting it for the other players it's world space position updates would still be correct right?
6 Replies
kapa.ai
kapa.ai2w ago
Hi @cryptomax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, I can offer some important insights about RealtimeTransform behavior in relation to parenting in NormalVR's Normcore system: 1. RealtimeTransform does not support reparenting. The RealtimeTransform documentation (https://normcore.io/documentation/realtime/realtimetransform#extra-notes) explicitly states that you should not reparent game objects with RealtimeTransform on them. 2. RealtimeTransform does not track or synchronize the parent of a RealtimeTransform at runtime. This means that if you parent an object on one client, this parenting relationship will not be replicated to other clients. 3. When using RealtimeTransform without a Rigidbody (in Transform mode), it synchronizes the localPosition, localRotation, and localScale properties, not world-space values. This is done to maintain precision and handle transform hierarchies correctly. 4. If you reparent a RealtimeTransform object under another game object, and that parent object is destroyed, it will take the RealtimeTransform with it, leading to inconsistent state between clients. Given these points, the answer to your specific question is: No, the world space position of the child object would not automatically be correct for other connected players if you parent it locally on one client. The local parenting would affect the local transform values being synchronized, but since other clients don't have the same parent relationship, they would interpret these local values differently, resulting in incorrect world positions. To achieve the behavior you're looking for, the RealtimeTransform documentation (https://normcore.io/documentation/realtime/realtimetransform#extra-notes) suggests an alternative approach: Instead of reparenting, create an empty game object on your player character at the pick-up point. Then use a script that synchronizes the world position of the pick-up point object and the RealtimeTransform object that you would like to pick up. This gives you visually the same result and avoids bugs related to reparenting. If you need to implement functionality similar to parenting at runtime, it's recommended to create an empty prefab with a RealtimeTransform component on it. When you need to temporarily track the position of an object, instantiate the prefab and synchronize the position between it and the object you're trying to move dynamically. Remember, when working with Normcore's networking system, it's crucial to avoid reparenting RealtimeTransform objects to maintain consistent behavior across all clients. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
cryptomax
cryptomaxOP2w ago
@Normcore Assistant ah so in this case it would be best to simply sync a vector3 and use that for the position updating
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Yes, you're on the right track! Based on the information from the knowledge sources, synchronizing a Vector3 for position updating would be a good alternative approach in this case. This method aligns well with Normcore's recommended practices for handling object positioning without relying on parenting RealtimeTransform objects. To implement this, you would: 1. Create a custom RealtimeComponent that includes a Vector3 property in its model for position. 2. Synchronize this Vector3 across all clients. 3. Use this synchronized Vector3 to update the world position of your object on all clients. This approach allows you to maintain consistent positioning across all clients without the complications that arise from parenting RealtimeTransform objects. For implementing custom data synchronization like this, you can refer to the Synchronizing custom data (https://normcore.io/documentation/realtime/synchronizing-custom-data) guide mentioned in the RealtimeComponent documentation (https://normcore.io/documentation/realtime/realtimecomponent). Remember, when working with Normcore, it's crucial to design your synchronization strategy in a way that maintains consistency across all clients, and using a synchronized Vector3 for position is a good way to achieve this in your specific case. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Mechabit
Mechabit2w ago
if it has a rigid body it'll sync world space and you can sync reparenting if you gave every object a unique id

Did you find this page helpful?