Hello,
I decided I wanted to recreate this WarioWare microgame in 3D for really no reason last night: https://www.youtube.com/watch?v=nijBAdk-JmA
As you can see in this game, you play as the white ninja and your inputs are left and right to go clockwise and counterclockwise around the tunnel respectively.
I have managed to recreate this, and if you go in only one direction or don’t change directions very much, it works fine… however, if I change directions too much (like if I spam left and right) then the character starts floating upwards:
Here is the relevant code:
private void FixedUpdate()
{
switch (state)
{
case PlayerState.Idle:
break;
case PlayerState.MovingLeft:
transform.Rotate(new Vector3(0, 0, -_rotationRate * Time.deltaTime));
transform.Translate(new Vector3(-_movementRate * Time.deltaTime, 0, 0));
break;
case PlayerState.MovingRight:
transform.Rotate(new Vector3(0, 0, _rotationRate * Time.deltaTime));
transform.Translate(new Vector3(_movementRate * Time.deltaTime, 0, 0));
break;
}
}
What is a better way I could do this? For the enemies this solution works fine since they don’t change directions, but I was thinking maybe it would be better if the player followed like a set circular path rather than this solution. Any other suggestions to try?
Thanks!