Hi
I need help mam as the object rotates round the axis of the black cube. Because now object rotating own axis not black cube, as in image number 2.I want to just copy the rotation black cube on axis x. Exactly the same way if it were a child of black cube but it is not
I want rotate object around black cube, ONLY if black cube rotate (i dont want rotate object all time around black cube), as in umage number 3… Can someone help me?
Thanks for reply
Parent it to black cube, or use transform.RotateAround()
If I’m right unless transform.RotateAround () does not work only if i want copy rotation of object. transform.RotateAround () will rotating all time around object… or not?
Is english your native language, because i didn’t get, what you said there?
transform.RotateAround works like transform.Rotate, except here you gan give it a point, and the object will rotate around it
this code snippet checks the black squares rotation, and rotate’s, if it changed:
var BlackSquare : GameObject;
var currentRot : float;
function Start() {
currentRot = BlackSquare.transform.rotation.y;
}
function Update() {
if (BlackSquare.transform.rotation.y != currentRot) {
transform.RotateAround(BlackSquare.transform.position, Vector3.up, BlackSquare.transform.rotation.y - currentRot);
currentRot = BlackSquare.transform.rotation.y;
}
}
But i don’t have the time to check it, so it might give an error.
oh thanks! up to now i mean transform.RotateAround not working like that… Sorry english is not my native language
And By the way, don’t repeat your questions, because you may get banned for that:
http://forum.unity3d.com/threads/unity-developer-network-rules.151494/