Log in or register to post comments

[Q] rotating an object attached to a marker towards the camera

March 13, 2017 - 9:21am #1

Hi,

 

I'm trying to rotate an object which I have got attached to a marker towards the camera. Like a billboard which should always be readable. I know this question pops up again and again but I still cannot make it work. At first, when the marker is stationary on the table it seems to work but after I've rotated the marker a couple of times the orientation of the billboard is completely off.

Ideally, I want place a flagpole on my Vuforia marker and then have the flag itself rotate towards the camera as much as possible whilst the flagpole itself stays normal to the marker.

My ARCamera is set to FIRST_TARGET. Is this not correct?

Can anyone point me in the right direction?

 

I used:

var newRotation = Quaternion.LookRotation(transform.position - Camera.main.transform.position);

  //newRotation.x = 0.0f;

  //newRotation.y = 0.0f;

  transform.rotation = newRotation;

 

 

[Q] rotating an object attached to a marker towards the camera

March 15, 2017 - 1:14am #2

OK, found it, this work well for me:

 

Vector3 targetPoint = new Vector3(Camera.main.transform.position.x, transform.position.y, Camera.main.transform.position.z) - transform.position;

transform.rotation = Quaternion.LookRotation (-targetPoint, Vector3.up);

Log in or register to post comments