4 Replies
Hi @MasterOX 水. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To instantiate a prefab under a parent with Realtime in NormalVR, you can use the
Realtime.Instantiate()
method. This method instantiates a realtime prefab in the scene on all clients. The fully instantiated game object, along with all RealtimeViews and RealtimeComponents, will be initialized and ready for use immediately.
Here is an example of how to use Realtime.Instantiate()
:
However, it's important to note that Normcore does not synchronize parent relationships between objects. If the new parent gets destroyed, it will take the RealtimeView and its components with it, which can result in desyncs between your clients. Therefore, it's generally recommended not to reparent a game object with a RealtimeView or RealtimeComponent on it (source (https://normcore.io/documentation/realtime/common-questions#can-i-reparent-a-game-object-with-a-realtimeview-or-realtimecomponent-on-it)).
Also, RealtimeTransform does not support reparenting (source (https://normcore.io/documentation/realtime/common-questions#can-i-reparent-realtimetransform)).
For more information, you can check out the Realtime.Instantiate() documentation (https://normcore.io/documentation/reference/classes/Normal.Realtime.Realtime).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@758040514678489279> kapa.ai is still learning and improving, please let us know how it did by reacting below
read this last paragraph : https://normcore.io/documentation/realtime/realtimetransform#dont-reparent-game-objects-with-realtimetransform-on-them
RealtimeTransform | Normcore Documenation
RealtimeTransform is a built-in RealtimeComponent that can be used to synchronize the transform or rigidbody of a GameObject.
parenting isn't supported out of the box
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