I have been setting up Live Link, specifically the fusion mode. I see the option to manually offset position but is there an out of the box way of rotating the character (or the ZED space)? Currently I only need single person tracking and I have tried to:
- rotate the “Unity Avatar” prefab’s transform - nothing happens.
- adding an offset value to worldGlobalRotation in ZEDBodyTrackingManager as soon as it is assigned from data (line 246) - the avatar does rotate but it’s walking path/ walking direction is still original. Imagine I rotate the character to align with global X axis but when I start walking the avatar walks in slant direction while facing straight towards X axis.
- directly overwrite animator’s body rotation and root rotation properties - same result as last case
Thank you so much for your assistance!
Hi @Milu, welcome to the forums!
Your second point seems promising, but you also need to update (apply the transformation from the old to new origin) the positions of the keypoints when filling
worldJointsPos at line 243. The first element of this array is used for the
bodyPosition of the animator later on, which is where your avatar will effectively be.
@JPlou Thank you for your reply! @Milu and I have been working together. If I understand it correctly, do I need to manually overwrite the position of the root after offsetting worldGlobalRotation? Below is the current state of UpdateCharacterControl. I haven’t thought through the math I have to do but I’ll try.
I wrote the following and it kinda works:
Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(animator.angleOffset), Vector3.one);
worldJointsPos = rotationMatrix.MultiplyPoint(worldJointsPos);
However, when ZED loses track of the character for a quick sec and refinds the skeleton, the avatar freaks out. I guess I need some way to rotate the entire ZED space instead of modifying the character like this
@MarioYang, yeah that function is the most “low-level” in terms of body tracking data, I think that’s where you should modify things.
What do you mean by “the avatar freaks out”? Can you send a video of it? Sounds like a bug. Maybe it’s the animation smoothing setting that’s too high when the character spawns.
I don’t know a way of modifying the whole space, I think editing the function like you did should do the trick. I suppose you could also make the spawned avatars children of a gameobject and adjust this object’s position and rotation, but the animator manages its position in world space I think, so you’d have at some point to change the reference system anyway.