Heya, guys.
I am trying to create a simple 2d game, with a flying thing that you push upwards and rotate the direction of “upwards”.
The problem I am having is that the gameobject keeps falling over through z-axis, a thing you never want in a 2d game, as it cant get back on its feet anymore.
Is there a way to totally disable movement through z axis?
What I have so far:
{
public float PlayerSpeed;
// Update is called once per frame
void Update ()
{
//amount to move
float amtToMove = Input.GetAxisRaw("Horizontal") * PlayerSpeed * Time.deltaTime;
float amtToFly = Input.GetAxisRaw("Vertical") * PlayerSpeed * Time.deltaTime;
//move the player
transform.Rotate(0 , 0 , Input.GetAxis("Horizontal") * PlayerSpeed);
transform.Translate(Vector3.up * amtToFly);
}
}