Hi,
I wanted to make a game similar to Fuzion Frenzy’s Twisted Sytems mini-game. In Twisted Systems four players are endlessly running around a spiralling tower and must duck and jump obstacles.
So I modelled a quick 3D tower. In Unity, I have it in three segments and moving downwards. Once a segment goes off screen it respawns back to the top of the stack. At this point when the tower respawns it instantiates either a duck or jump obstacle from an array at certain transform points around its neck.
I then tied the camera and the player to a central gameObject I called pivot that was at 0,0,0 in the centre of the tower. I made a rotation script on this. So the camera and player rotate around the tower. The tower at the moment does not rotate.
From here I created a GameManger that sat over all the gameobjects and could control the rotation speed of the pivot, and the downward descend speed of the tower.
But this quickly became way more complicated than I am capable of. No matter what I do I cannot get the descending speed of the tower and rotation of the player/camera to sync up. What I am aiming for is the camera and player to be fixed at the same point of the towers path descent (I hope I’ve explained that correctly, but identical to the first gif at the top of this question). I’ve tried lots of combinations (rotating the tower, making the player slowly rise up, etc) but I know it requires more thinking.
I started trying to place an inverted rotation on the player and camera that goes against the tower (using transform.rotation = Quaternion.Inverse(tower.rotation)), but this didn’t work. And I have a feeling I’m into the place where I may have to use quarternions or some form of angles to be able to get the character and camera pivot to be inversely rotating against the towers descent. I know at the moment that I want the player and camera to be rotating, and it wouldn’t be good to have the player actually climbing (given this is an endless runner).
Any suggestions on how I could implement this? Any replies really appreciated. Thank you.
UPDATE: SOLVED
After lots of reading around, I manage to solve this by diving into EulerAngles and Quaternion rotations.
private const int objHeight = 2;
public float speed = 2;
private void FixedUpdate()
{
transform.position += Vector3.down * speed * Time.fixedDeltaTime;
transform.rotation *= Quaternion.Euler(0, 360 / objHeight * speed * Time.fixedDeltaTime, 0);
}