Hi
During experiments with an Optitrack system and a Unity I noticed an issue that is likely related to the issue described in the optitrack docs for this usecase.
As I understood it, when animating an characters in Unity , the position, scale and rotation of the characters are done in reference to the origin of the Unity project (whether this is due to how Optitrack streams the data, or how Unity reads it I don't know). This causes some issues as changing these parameters will have undesired effects, for example rotating the characters by 180º won't turn it in place but instead move it across the project to the other side of the origin, or (relevant below) scaling the characters down will move it closer to the origin.
I tried not touching these parameters but then noticed that Optitrack seem to be already doing some scaling in the background (or expects the characters to be scaled to match the reported tracked skeleton) and creates an offset by default. So for example, if the characters in Unity is left unscaled (set to (1,1,1)) leaving it at its original height of 180cm, but the real person in the Optitrack suit is smaller/taller than that, the characters will be placed closer/ further from the origin than it should be.
This problem doesn't affect rigid bodies, as Optitrack doesn't seem to do any scaling with them (i.e. the tracked rigid body can be tied to a GameObject that is way bigger or smaller). Optitrack doesn't seem to "expect" the tied GameObject to be of the same size as the real rigid body. I'm pretty sure this difference is what cause the offset problem described in the docs, where the position of the character doesn't match the one from the rigid body.
The work around I found is to turn on the marker visibility in Unity and then manually set the scaling of the characters until it moves into the correct position inside the marker "cloud". Once this is done the tracking is accurate and the position matches the position of rigid bodies. This works with the character that Optitrack provides (Ethan) as well as with others. The needed scaling is definitely linearly dependent on the size of the person in the Optitrack suit, but not perfectly (although that might be due the participants not reporting their size 100% correctly)
So here are my questions:
Is there a way to get from the optitrack client script or the skeleton animator script the "expected size" of the character in unity when I start the unity game. As the problem seem to arise from a mismatch between the size of the skeleton optitrack reports and the size of the character, I could automate the scaling of the character based on the size of the optitrack skeleton to correct this offset.
Or is there maybe a way to deactivate this dependency of the scale of the character. Optitrack knows and streams the real position of the markers, so maybe there is a way to ignore the scale of the character and just place it in the correct position?
Thanks in advance and sorry for the long text!
Unity skeleton animator offset due to scaling (with manual work around)
-
- Posts: 1
- Joined: Wed Mar 05, 2025 9:06 pm
- Contact:
Re: Unity skeleton animator offset due to scaling (with manual work around)
Your support is invaluable. Thank you so much!