scene object

if i have a sceneobject with a model (not instantiated, but included in the scene) is there a way to claim ownership of it? is the model synced by default? is it controllable?
3 Replies
kapa.ai
kapa.ai4w ago
Hi @Ryan Green | MONA. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, you can claim ownership of a scene object with a model in NormalVR. By default, anyone can request ownership of a RealtimeView at runtime. The server will approve this request unless a parent RealtimeView is already owned by another client. However, this can be controlled with the preventOwnershipTakeover flag. When this flag is true on any model, the server will deny any client’s attempt to change the ownership of an object in that model unless it has no owner source (https://normcore.io/documentation/room/ownership-and-lifetime-flags#prevent-ownership-takeover-of-a-realtimeview). The model is indeed synced by default. RealtimeComponent subclasses are the most common way to synchronize data in your application. A RealtimeComponent subclass script is responsible for keeping a specific part of your scene in sync. The most common built-in component is RealtimeTransform, which synchronizes the transform of a GameObject source (https://normcore.io/documentation/realtime/realtimecomponent). As for control, it depends on the ownership. If the object is owned by the local client, then it is controllable by that client. If it's owned by a remote client, then it's controlled by that remote client. If the object is unowned, then it's not controllable until a client takes ownership source (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeComponent%601). Here's an example of how you can request ownership of a RealtimeTransform, which is a RealtimeComponent subclass:
public void CreateObjectAndRequestOwnershipOfRealtimeTransform() {
// Instantiate the My Object prefab, leave the view unowned.
GameObject myObject = Realtime.Instantiate("My Object", ownedByClient: false);

// Get the RealtimeTransform component
RealtimeTransform realtimeTransform = myObject.GetComponent<RealtimeTransform>();

// Request Ownership
realtimeTransform.RequestOwnership();
}
public void CreateObjectAndRequestOwnershipOfRealtimeTransform() {
// Instantiate the My Object prefab, leave the view unowned.
GameObject myObject = Realtime.Instantiate("My Object", ownedByClient: false);

// Get the RealtimeTransform component
RealtimeTransform realtimeTransform = myObject.GetComponent<RealtimeTransform>();

// Request Ownership
realtimeTransform.RequestOwnership();
}
source (https://normcore.io/documentation/room/ownership-and-lifetime-flags#requesting-ownership-of-any-realtimecomponent-or-realtimemodel) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@337874773742845953> kapa.ai is still learning and improving, please let us know how it did by reacting below
maxweisel
maxweisel4w ago
This answer is correct. The same methods for synchronizing models on prefabs apply to RealtimeViews in the scene too.