Boss size and rotation not syncing (I think)
In my game i have a boos fight. We have the following script that spawns the boss and handles movement when a player steps into an invisible collider. The boss spawns and rotates and works, but for the player that doesnt spawn the boss the size and rotation are different.
this is the script:
3 Replies
Hi @✨Mike the Floof Wizard✨. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Your issue—where the boss's size and rotation are not syncing correctly for all players—likely stems from how and when you are synchronizing these properties with Normcore's datastore.
Key Points from Normcore Documentation
1. Synchronization Must Use the Model
For properties to sync across clients, you must update the model, not just the transform. In your
Only the owner of a
See: RealtimeTransform and Ownership 3. Model Updates Should Be Consistent
You should update all properties you want to synchronize (position, rotation, scale) in the same way. If you only update rotation in
In your
Before making changes, ensure the local client owns the component: (You may want to do this in
Make sure you are not trying to sync before the model is ready. Use
Synchronizing custom data Additional Notes - Reparenting: Normcore does not synchronize parent relationships. If you reparent the boss, this will not be synced to other clients and can cause desyncs.
See: Can I reparent a game object with a RealtimeView or RealtimeComponent on it? - Prefab Instantiation: Make sure you are using
See: Synchronizing a GameObject Summary - Update all properties you want to sync (rotation, position, scale) on the model, not just the transform. - Ensure the local client has ownership before making changes. - Do not rely on reparenting for synchronization. - Use
- RealtimeComponent
- Synchronizing custom data
- Realtime common questions
- RealtimeTransform ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
For properties to sync across clients, you must update the model, not just the transform. In your
Update()
method, you only set model.rotation = transform.rotation;
but you do not update the model's scale or position there. If the scale is changed locally but not written to the model, it will not sync to other clients.
2. Ownership Is Required for SyncingOnly the owner of a
RealtimeComponent
can update the model. If the local client is not the owner, changes to the transform will not be propagated. Make sure the client moving/rotating/scaling the boss has ownership of the component. You can request ownership using RequestOwnership()
on the component or its RealtimeView
as appropriate.See: RealtimeTransform and Ownership 3. Model Updates Should Be Consistent
You should update all properties you want to synchronize (position, rotation, scale) in the same way. If you only update rotation in
Update()
, but not scale, scale changes will not be sent to the model and thus not synced.
How to Fix
- Update the Model for All Synced PropertiesIn your
Update()
or wherever you change the boss's transform, set all relevant model properties:
- Ensure OwnershipBefore making changes, ensure the local client owns the component: (You may want to do this in
Start()
or before you start moving the boss.)
- Check Model InitializationMake sure you are not trying to sync before the model is ready. Use
OnRealtimeModelReplaced
for initialization logic, as described in the docs:Synchronizing custom data Additional Notes - Reparenting: Normcore does not synchronize parent relationships. If you reparent the boss, this will not be synced to other clients and can cause desyncs.
See: Can I reparent a game object with a RealtimeView or RealtimeComponent on it? - Prefab Instantiation: Make sure you are using
Realtime.Instantiate()
to spawn the boss, not Unity's Instantiate()
, so that all clients instantiate the object in sync.See: Synchronizing a GameObject Summary - Update all properties you want to sync (rotation, position, scale) on the model, not just the transform. - Ensure the local client has ownership before making changes. - Do not rely on reparenting for synchronization. - Use
Realtime.Instantiate()
for spawning networked objects.
If you follow these steps, the boss's size and rotation should sync correctly for all players. If issues persist, double-check that your model events (rotationDidChange
, scaleDidChange
, etc.) are firing and being handled on all clients.
---
References:- RealtimeComponent
- Synchronizing custom data
- Realtime common questions
- RealtimeTransform ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@372679700885012485> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Is that script running on all the clients? looks like MoveTraget would override whatever's in the data store
if the boss rotates at a fixed rate you can just sync the start time and the players can calculate the current rotation from the room time