- Home /
Creating a 'rotation' system
Hi guys
In my Volleyball Sports Management sim Im looking to create a rotation system where the after every point the players rotate position in a specific order. Then in each situation I can simply program the GameObject which is currently in that position to move to a specific spot or do a specific action. I currently have
public GameObject position1;
public GameObject position2;
public GameObject position3;
public GameObject position4;
public GameObject position5;
public GameObject position6;
public GameObject position7;
public GameObject position8;
public GameObject position9;
public GameObject position10;
public GameObject position11;
public GameObject position12;
And have set the starting positions by simply dragging the objects in place using the inspector but am a bit lost in working how how to edit the players position in the script. (e.g. During a rotation, position 6 move to position 5, 5 to 4, 4 to 3 etc)
Any help would be much appreciated!
depends on how you move the players.. 1 way would be to use https://docs.unity3d.com/Documentation/ScriptReference/Vector3.Lerp.html
Vector3.Lerp(position6.transform.position, position5.transform.position, fracJourney);
and so on
Answer by trololo · Mar 19, 2014 at 03:19 PM
You should use a GameObject array instead of several variables. That way you could easily facing each player to the previous position:
if(i > 0) Transform.LookAt(position[i - 1]);
If you want a smooth rotation, you can launch a coroutine for each player and use a Lerp() function as it has been said.
Your answer
Follow this Question
Related Questions
Error message "variable not assigned" ? 1 Answer
HELP! is this a Bug in the game engine? 1 Answer
Help Me with my gun! 1 Answer
Is it possible to show Static Variables in the Inspector? 10 Answers
UnassignedReferenceException: The variable enemy of EnemiesSpawner has not been assigned unity3d 0 Answers