I have a networked VR experience in which players can grab objects using their controllers by intersecting a mesh and squeezing the grip.
In the browser of player A, I parent the grabbed object B, to player A’s hand using something like:
objectB.setParent(playerALeftHand)
When this happens I need to broadcast an event to all the other players that player A has grabbed object B so that each of the other players can also do that parenting in their respective browsers. I’m trying to figure out what schema to use for the message:
If I do { object_id: "object B", grabbed_by: "player A left hand" }
, the receiving browser only knows it should parent the grabbed thing into the correct mesh, but it doesn’t know what the precise positions, rotations, offset are to maintain the exact same parent/child relationship as the event source. If player A is grabbing object B in a certain way, I want all other clients to reproduce the parenting relationship/grabbed angle etc in the exact same way.
Grabbing an object is flexible. For example a stick can be grabbed anywhere, at the middle, at the end, at any angle, and you can hand it from one hand to another etc.
I can send the positions and rotations of both the hand doing the grabbing and the object being grabbed at precisely the time the controller grip is squeezed, leading to an event like this:
{ object_id: "object B", grabbed_by: "player A left hand", hand_pos: [...], hand_rot: [...], obj_pos: [...], obj_rot: [...] },
which will work to capture the relationship between the parent and child, however I don’t quite like this solution because it expresses the relationship through an event in the past, rather than capturing the essence of the relationship. If a new player joins later and needs to know what each player is holding and how they are holding it, I would like to find a schema that efficiently describes those relationships without needing to express them in terms of former positions.
I feel like there is some kind of matrix or other value I can send to capture the essence between a parent and child, to help me parent things on the receiving clients, no matter where the hands are located at the time the message is received.