js/unity3d -2d billboarding question

Started by
0 comments, last by jefferytitan 9 years, 5 months ago

Hi all. This video explains better

I have a 2d plane sprite in a 3d world. Of course when the cam comes to or is at the left/right of the plane, the plane will seem to disappear. I am trying to get it to rotate at least 30 degrees at that point towards the left/right depending on the cam position, so it will never 'disappear'.

the closest i came to this was in this attempt

  1. var checks : float[];
  2. var myRots : float[];
  3. if(Mathf.Clamp(cam.transform.eulerAngles.y, checks[i]-5, checks[i] + 25) == cam.transform.eulerAngles.y)
  4. transform.localEulerAngles.y = transform.parent.transform.rotation.y * myRots[i];

Here i manually input camera rotations into the checks string, and when the cam rotation is that rotation, i tell the character to rotate itself a specific amount with the 'myRots' string. This only works until the character itself rotates, then the everything i set becomes incorrect. The character is in an empty gameObject. I rotate the parent obj when moving in the world, and rotate the actual plan as needed for the camera. I don't control it with the keys, but it will wander around. Any help is deeply appreaciated!

Advertisement

Do you want it to be a true billboard, e.g. always completely facing the camera? If so, this would be the sort of thing you'd want:

http://wiki.unity3d.com/index.php?title=CameraFacingBillboard

This topic is closed to new replies.

Advertisement