gubebra
gubebra7mo ago

Moving a kinematic body with .MovePosition() sometimes doesn't update the position for all players

I've been experiencing strange results with moving rigidbodies with my own velocity calculation using MovePosition. For the owner of the object everything works fine but sometimes other players can't see the object moving.
13 Replies
kapa.ai
kapa.ai7mo ago
Hi @gubebra. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- This issue might be related to the ownership of the RealtimeTransform component in NormalVR. In a multiplayer environment, a game object and its transform can exist on multiple clients. This means that there are multiple copies that all claim to know the position of this object, but only one of them can be considered the source of truth. This is where ownership comes in. RealtimeTransform treats the client that owns the object as the source of truth. All other clients follow along with the owner's copy of the transform or rigidbody. This means that in order to move an object with a RealtimeTransform component on it, you must be the owner of the RealtimeTransform component. You can request ownership of a RealtimeTransform component by calling RequestOwnership() or by using the Request Ownership button in the editor inspector. A RealtimeTransform is available for immediate use after RequestOwnership() is called. Normcore will assume the call is going to succeed, and will roll back any state changes automatically if the call is rejected by the server (source (https://normcore.io/documentation/realtime/realtimetransform#how-it-works)). If you're trying to directly move an object, make sure to mark it kinematic. Doing so lets PhysX know that you're controlling its position and it should not simulate the object directly. It also tells RealtimeTransform that it should not clear ownership when the object goes to sleep (source (https://normcore.io/documentation/realtime/networked-physics#realtimetransform--physics)). Also, if you've added a RealtimeTransform component to your game object and it keeps getting reset back to where it started, this is why. You're not the owner, and therefore the datastore values are treated as the source of truth (source (https://normcore.io/documentation/realtime/networked-physics#ownership--physics)). Lastly, if the RealtimeTransform object has a Rigidbody on it, make sure to use the MovePosition() and MoveRotation() methods in FixedUpdate() (source (https://normcore.io/documentation/realtime/realtimetransform#dont-reparent-game-objects-with-realtimetransform-on-them)). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@599054560270483456> kapa.ai is still learning and improving, please let us know how it did by reacting below
maxweisel
maxweisel7mo ago
You’re moving it once right? not over multiple frames?
gubebra
gubebraOP7mo ago
Hi Max, I'm moving it for multiple frames The player is holding the object and moving around
maxweisel
maxweisel7mo ago
@NormalMark this is a bug I’d love to include in the bug bash. It goes out in a single unreliable packet and gets dropped. Chris wrote some tools to make it so we can make an “unreliable reliable” property that sends a final reliable packet after the property hasn’t changed for a network frame. oh interesting. and none of the frames update or you see a dropped frame occasionally?
gubebra
gubebraOP7mo ago
No, the object doesn't move for some players even when the owner is holding it. Everything seems to be right, the owner, the movement and of course the owner sees the object moving in his hand
maxweisel
maxweisel7mo ago
do any other remote players not see the movement? this sounds like potentially an ownership issue
gubebra
gubebraOP7mo ago
I do disable/enable the gameObject sometimes to save some processing. But I made sure to do it some frames before and all players have the object active before anyone has the chance to grab it No And it seems to be only happening sometimes
maxweisel
maxweisel7mo ago
if the data is making it to the server and out to other clients, it’s hard for me to imagine how some clients aren’t processing it. that said enabling / disabling the game object could definitely mess that up. RealtimeComponents don’t support that very well. Instead we recommend turning off other components / renderers or making a child game object that you enable/disable and put everything else on that
gubebra
gubebraOP7mo ago
Oh so you're saying instead of disabling the realtimeComponent add a child to that object (the meshRenderer) and only disable that?
maxweisel
maxweisel7mo ago
yeah
gubebra
gubebraOP7mo ago
Alright makes sense, I'm going to try doing this then, thanks fo the help Max
maxweisel
maxweisel7mo ago
sure thing!