Software Archive
Read-only legacy content
17061 Discussions

Tracking Aciton teleporting GameObject on Unity

Lucas_M_2
Beginner
377 Views

Hello guys!

I wanted to know if there's a way to fix GameObject's position with the Tracking Action script.
I have a object that seems to be moving to the center of the virtual world box when the Tracking Action script is activated, but I want for it to stay close to left side of the virtual world box.
Is there any way I can control a object from it's initial position, instead of having it teleported?

Thanks,
Lucas

0 Kudos
3 Replies
MartyG
Honored Contributor III
377 Views

Do you mean the position jumps when tracking is acquired?  If so, there's likely not much that can be done to prevent it.  I've tried ever since RealSense's launch to write a system to eliminate this leap, with no luck.  On start-up, the object is basically leaping to wherever the landmark being tracked is.

An example in the full-body avatar in my own project is that if the RL hand is in front of the chest, the virtual arm will jump sidewards towards the avatar's chest on start-up as it leaps to the position of the RL landmark. Likewise, if you have your RL head dipped when face tracking is acquired then the avatar's face-driven legs automatically crouch down.

Since I could not eliminate the jump, I ended up building a compromise - a script that auto-resets the object to the desired position when tracking is acquired, so the object leaps to its correct position a moment after the TrackingAction mis-locates it.

This C# script from my project, shown below, should cause an object containing the script to automatically rotate leftwards whenever the hand or face stops moving.  I don't have a version of it (yet) for resetting Position based movement but you might find it useful somehow.

void Update () {

var newRotation = Quaternion.LookRotation (Vector3.left).eulerAngles;

transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(newRotation), Time.deltaTime);

}
}

If your object tips up and down instead of left and right, change Vector3.left to Vector3.forward

Oh, I've just remembered another example in my project where I compensate for the jump in a Position-based object.  The avatar's mouth uses Position, and on the start-up jump, the mouth would automatically jump open.  So how I compensated was to place a small decimal-point value in the Center box directly above the Virtual World Box values.

For example, my mouth used a Y axis value of 0.9 in its Virtual World Box.  I gave the Center box of the Box's Y axis a value of 0.15.  Because I was effectively moving the top edge of the Box up into the face instead of having it centered in the middle of the mouth, the mouth no longer hung open when tracking was acquired.  It was still mis-moving but because the box center had been defined as being 0.15 off-center in the Y direction, the mouth no longer hung open when tracking began.

0 Kudos
Lucas_M_2
Beginner
377 Views

That's exactly what I meant!
Maybe the best solution for this right now is to tell to user to position his hands accordingly to the position I want before starting the tracking script.I tried to update the object position by script, but it didn't get the effect I was looking for.
Thanks for your help Marty, you are helpful as always, keep up the good work! 

 

0 Kudos
MartyG
Honored Contributor III
377 Views

Being able to disable the position-leaping would definitely be at #2 in my top 2 list of desired features, with number 1 being able to tick a box to stop objects rotating when the wrist is turned.  I've been asking on this forum for wrist-disabling to be included in the SDK since Sept 2014 and nothing has ever happened, so I don't have much hope for an official anti-leaping option being provided either.  

I can understand why they'd have trouble with a wrist turn-off option though.  The problem isn't exactly with the wrist joint.  The way the camera handles rotation is that if the RL hand moves up-down-left-right, the camera interprets it as rotation even if a bone joint in the hand is not physically rotating.  So when the hand moves up and down, for example, the joints in my avatar's virtual hand were rotating and flexing the fingers open and closed, even though the fingers on the RL hand were not actually opening and closing.  You can see this effect on the Unity virtual hand example packaged with the SDK.

In the absence of official solutions, I always build counter-measures myself and publish them on this forum.  For example, how I solved the hand flexing issue was to set up trigger fields in Unity that switched off the rotation in the finger joints if the hand was position-moved, and only allowed the fingers to be opened and closed when the RL hand was stationary.

Actually Lucas, you reminded me of something that might be helpful for your problem.  My latest invention was to put a TrackingAction inside an object that sits on its own with nothing attached to it.  The object that needs to be rotated then reads the angle or position of the TrackingAction-equipped object and uses that as its angle or position instead of having a TrackingAction directly inside it.

The advantage of doing things this way is that the rotation behavior of objects can change depending on what you have attached to them, and the physical size of the TrackingAction-equipped object.  The movement behavior of a standalone objects tends to be more stable and position-jump less than an object that is rotating as part of a greater structure of multiple linked objects. 

I'll link you a guide I wrote recently on the subject.

https://software.intel.com/en-us/forums/realsense/topic/606630

0 Kudos
Reply