Destroy Object
How do I destroy and an object that has the real time and the real time transform components?
2 Replies
Hi @fgamez1020. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To destroy an object that has Realtime and RealtimeTransform components in NormalVR, you should use the
Realtime.Destroy()
method instead of Unity's standard GameObject.Destroy()
. Here's how you can do it:
This method must be used for GameObjects that were instantiated with Realtime.Instantiate()
. It ensures that the object is properly destroyed across all clients in the networked environment.
It's important to note that typically, you should only destroy objects that are owned by the local client. A common pattern is to check for ownership before destroying:
This helps prevent issues where multiple clients might try to destroy the same object simultaneously.
For more details on destroying Realtime prefabs, you can refer to the Room > Server Authority + Ownership + Lifetime Flags documentation.
Remember that you cannot add or remove RealtimeTransform components at runtime, as mentioned in the RealtimeTransform Extra notes. If you need to temporarily track an object's position, it's recommended to use a separate prefab with RealtimeTransform that you can instantiate and destroy as needed.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1053407831916822528> Kapa.ai is still learning and improving, please let me know how I did by reacting below.