- Home /
Rotate an Object
Hello Unity3D.I have a question about rotating an object.How can i rotate an object from another object?For example.I want my character summon an orb and then i want that orb to rotate or orbit around the character.that summoned the orb.If anyone knows how i can do this?Can you please tell me how?I can;t seem to find it
Answer by Vice_Versa · Jun 29, 2015 at 07:31 PM
on the orb objects attach a script that has this
public Transform targetObject; // your player
Vector3 rotationMask = new Vector3(0, 1, 0);
public float rotationSpeed = 5.0f;
void Update()
{
transform.rotateAround(targetObject.transform.position, rotationMask, rotationSpeed * Time.deltaTime);
}
2 things. 1.Would this work if i put this in javascript format 2.Is there a way i can put this script on the character that summons the orb or does the script have to be on the orb at all times in order work?
if the orbs are summoned as children of the player you could do transform.child.transform.rotateAround(etc.) i think it would make more sense to have it on the orbs though.
and yes, this will work in javascript as well
Your answer
Follow this Question
Related Questions
How do you flip a card with smooth rotation? 1 Answer
Rotate GameObject Issue 1 Answer
Object rotates with camera 2 Answers
Rotate object relative to camera's view 2 Answers