Going made with crazy object transforms

April 17, 2015 - 6:59am #1

Hi, I am using the V4.105 Unity plugin with Unity 5 to display a number of game objects orbiting a tracked item with each game object using the LookAt script below.

On first detection this works perfect and losing then reacquiring fix the game objects perform exactly as expected.

However if I then lose the fix and acquire a fix on a different target and that performs as it should with a totally different unrelated process then move back to the original tracked item I am finding the orbiting game objects are either on their sides, upside down or some other weird orientation?

I have tried numerous ways from setting active on off, checking rendering etc (last attempt in script below) but still the orbiting game objects go bonkers....pretty much like my brain at the moment!

Can anyone help please?

publicclassLookAtCamera : MonoBehaviour {

privateRenderercomponent;

privateVector3defPos;

privateQuaterniondefRot;

voidStart() {
component = GetComponent<Renderer> ();

defPos = transform.position;
defRot = transform.localRotation;
}

//Updateiscalledonceperframe
voidLateUpdate () {

if (component.enabled) {
Debug.Log("rotate");
//simples...make this gameobject look at the camera
transform.LookAt (Camera.main.transform.position, -Vector3.up); 
}
else {
Debug.Log("reset");
transform.position = defPos;
transform.localRotation = defRot;
}
}
}



Thanks

Going made with crazy object transforms

April 20, 2015 - 11:49pm #5

!!!! GROAN !!!!

 

So simple really!  

 

ARCamera world centre = camera

 

!!

;-)

Going made with crazy object transforms

April 20, 2015 - 2:03pm #4

Can one of the mods assit please?

I have deduced that the offending line of code is this:

  transform.LookAt (Camera.main.transform.position, -Vector3.up); 

To clarify when object target is found I have a number of models that appear and rotate around it and look at the camera as they rotate.  As the target is lost and found again they continue to rotate and look at the camera correctly.

But...

If I lose the object target and find the image target that is in the same scene and therefore using the same ARCamera the image target augmentation works correctly.

If I then lose the image target and re-acquire the object target the models appear rotating aroung the target object but they of always tilted on their sides.

So what I cannot grasp is what is happening to the ARCamera between the finding and losing of the object target and the image target?

 

Please....Im at a loss...

 

 

 

Going made with crazy object transforms

April 20, 2015 - 1:36am #3

Everything works fine with the objects in the correct place as long as I remain tracking / lose trackin on the object target, howerver as soon as I move and get a fix on the image target and then return to the object target things go wrong.

 

So I can only deduce there is something going on between the found / lose of tracking between the object target and the image target?

Going made with crazy object transforms

April 19, 2015 - 8:54am #2

anybody got any ideas?

 

 

Topic locked