is there a way to rotate an object, on the current local axis of an other object?
something (this is not right) like this: transform.Rotate(-5,0,0,Space.GameObject.Find(“OtherObject”));
is there a way to rotate an object, on the current local axis of an other object?
something (this is not right) like this: transform.Rotate(-5,0,0,Space.GameObject.Find(“OtherObject”));
Do you mean Transform.localRotation ?
The rotation of the transform relative to the parent transform’s rotation.
If so ,just change its value.
Rotations are always tricky. If both objects have the same rotation at Start and have no parents, you can copy transform.rotation from one object to the other - the second object will follow any rotation applied to the first one. If they are childed to other objects, however, you may have lots of weird effects.
EDITED: There is a function to rotate an object around any arbitrary axis, RotateAround. You can set this axis to some local vector of another object: use .up vector for Y, .right for X or .forward for Z.
It’s not possible to rotate around more than one axis in a single RotateAround.
The example below rotate around the Y axis of the object defined in master:
var master: Transform; // reference object
function Update(){
var ang = Input.GetAxis("Horizontal") * 30 * Time.deltaTime;
transform.RotateAround(transform.position, master.up, ang);
}