- Home /
LookAt - Change rotation origin point?
So I have a cannon, and it is basically looking at wherever the Mouse is. So the rotation is constantly changing. But the cannon rotates around its center. And that's unnatural...
So my question is more like... how do I set a "origin point" for the cannon to rotate around it instead of its own center?
Answer by Yoerick · Nov 22, 2010 at 05:26 AM
The LookAt function rotates an object along its pivot point, which is set in the 3D model. If you change the pivot point inside your 3D modelling program (like 3DS Studio, Maya, Cinema 4D, ...) and reimport it, it should be ok ;)
edit: another (but less beautifull) way is to wrap the cannon in an empty object, set the center point of that empty object and add your script to this object ;)
Can't it be changed just with code? Because, I'm pretty new to Unity so currently I'm just experimenting some coding here and there and not working too much on models..
well there is a way to achieve that, using a script this guy wrote: http://solvethesystem.wordpress.com/2010/01/15/solving-the-pivot-problem-in-unity/
But I think the easiest way would be to change the pivot inside the 3D model or use an empty game object as a parent for the cannon.
Your answer
Follow this Question
Related Questions
LookAt - Change rotation origin point? 2 Answers
Camera rotate around sphere centre 2 Answers
Rotate Z-Axis towards center. 0 Answers
Reset GameObject Axis Origin at Model Center 1 Answer
Move the terrain to center on origin 0 Answers