- Home /
How do I rotate an object in relation to the camera?,How do I rotate a sprite in relation to the camera?
Hello! I am trying to make a sprite (of a mushroom) rotate in relation with my first-person character so that it is always seen from the front no matter what direction one approaches it. Essentially, I want the sprite to rotate in correspondence with camera. I haven't been able to find the specific answer to this problem anywhere.
Hope this makes sense!
Many thanks in advance!
Tom ,Hello! I'm trying to make a sprite (of a mushroom) to rotate in relation to my first-person character so that it's front is always facing the character's camera: so that from whatever angle the character approaches the sprite the front will always be seen. I hope that makes sense! Many thanks in advance!
Tom
Answer by ecv80 · Dec 11, 2018 at 03:04 AM
I'd think this would work: gameObject.transform.forward=-Camera.main.transform.forward;
Or maybe this: gameObject.transform.LookAt(Camera.main.transform);
They're not exactly the same. Give it a try?
Answer by howlbrett · Dec 11, 2018 at 03:15 PM
Thank you so much! This works perfectly! I've been struggling for ages with this - really appreciate your help.
Your answer
Follow this Question
Related Questions
Wonky Camera Behaviours 0 Answers
RTS type of camera 1 Answer
Sidescroller Turning 1 Answer
Rotate Character Controller Camera 0 Answers
Rotate a sphere in the same direction the camera is pointing at 2 Answers