|
I written up a script that allowed any one of my game objects to rotate in a circular motion however it always seems to reset the object to the center of the screen when I play the game and never to the position I started it from. I got no clue about how to go around this but I've been trying to look into it. If anyone can help me out thanks in advance.
(comments are locked)
|
|
Well, what you describe is exactly what you do there. Sin() and Cos() returns a value between -1 and 1. You multiply this value by your radius so the value is in between -radius and radius. Then you use it as absolute position. This way you will always rotate around 0,0,0 What you need is an offset. This can be saved at start like this: Ah I see it now. Thanks for the explanation!
Jul 28 '12 at 04:29 AM
TakMarche
I found myself stuck once again. What if my initial position is always changing (from another script) once the object is destroyed?
Jul 30 '12 at 02:51 AM
TakMarche
I don't get what you mean. When the object is destroyed, it's no longer there... When you instantiate a new object with that script, it will set it's initial position the first frame after it has been instantiated. You can make
Jul 30 '12 at 10:15 AM
Bunny83
Thanks for the explanation!I was finally able to figure it out.
Aug 01 '12 at 10:45 PM
TakMarche
(comments are locked)
|
|
You don't need to do all of that.. just make the object you want to move circularly a child of a stick (cube game object) , put your object at the tip of the stick... then attach a script to the stick to make it rotate function Update(){ transform.Rotate(0,0,Time.deltaTime); } make sure not to render the stick in camera.. the stick length is the radius of the circle.......
(comments are locked)
|
