- 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 duck · Nov 22, 2010 at 09:41 AM
The simplest way to solve this would be to parent your cannon model to an empty dummy gameobject, and offset the cannon position so that when you rotate the empty parent model, the cannon model rotates around the desired origin.
Either that, or open the cannon model in your 3D editing application and modify the origin/pivot directly!
Sorry I just want to check with you, I tried parenting my model to a dummy object but the origin of the parent is an aggregate position of both objects, am I doing something wrong?
Answer by Proclyon · Nov 22, 2010 at 07:59 AM
The transform is the method in which the Unity3D system and the PhysX engine actually perceive an objects "origin.
To create a rotation means to change the angle over the axis of the transform axes. Say 90 degrees over Y would make a standing character face right (absolute right, not relative right)
So rotating the object around another object by editing the origin point is not a possibility. You would have to set a radius of the circle around you move your cannon. How far from the target point is the cannon?
Once you have that you need to move (rotate around that target) by changing the position of the transform of the cannon. The x component is the cos value of the angle and y the sin value of the angle. Those two with the radius make for the distance and rotation around the object.
Complicated? Yes quite, I would strongly recommend looking if such a feature (Inbuilt method) does not already exist in Unity3D calls internal or to PhysX. That could save you a large amount of time.
Your answer
Follow this Question
Related Questions
LookAt - Change rotation origin point? 1 Answer
Reset GameObject Axis Origin at Model Center 1 Answer
Move the terrain to center on origin 0 Answers
Degree from point? 2 Answers
Make object face center of circle without flipping in 2D space. 0 Answers