Question by
Jack_Loomis · Feb 23, 2020 at 08:09 PM ·
2d-platformer
Why are my characters broken when I open a previous level?
I am making a 2D platforming game, and I am currently working on the third level. I switched back to the second and first level to make sure the UI in the third level was consistent with the two first ones. When I played the first two levels, the character moved way too fast, and didn't seem to follow the script i wrote for it. Even when I set the speed of movement to zero, they still moved. Why does this happen, and what can I do to get it back to the way it was before?
Here's my movement code:
if (Input.GetKey("d"))
{
rb.AddForce(transform.right * moveSpeed);
player.transform.rotation = new Quaternion(0, 0, 0, 0);
if (grounded == true)
{
animator.SetBool("Running", true);
animator.SetBool("Idle", false);
animator.SetBool("DashOrBoost", false);
animator.SetBool("Jumping", false);
}
if(grounded == false)
{
animator.SetBool("Running", false);
animator.SetBool("Idle", false);
animator.SetBool("DashOrBoost", false);
animator.SetBool("Jumping", true);
}
}
//Do stuff when a is pressed
if (Input.GetKey("a"))
{
rb.AddForce(transform.right * moveSpeed);
player.transform.rotation = new Quaternion(0, 180, 0, 0);
if(grounded == true)
{
animator.SetBool("Running", true);
animator.SetBool("Idle", false);
animator.SetBool("DashOrBoost", false);
animator.SetBool("Jumping", false);
}
if (grounded == false)
{
animator.SetBool("Running", false);
animator.SetBool("Idle", false);
animator.SetBool("Jumping", true);
animator.SetBool("DashOrBoost", false);
}
}
Comment
Your answer
