- Home /
With No Reason, My Character Stopped Looking To the Way She Goes.
Hi, I am Noam, I'm a beginner In unity and I made a game using unity. Till now all was good. I just tried to remake things I loved in other games. And today after adding an animation, My Character Just Stopped Moving to Her Right way. I didn't Make ANY change in the code and she just not Doing it.
Photo:
It started 2 weeks ago when I tried to make an item that changes her color and it didn't work. Even Manually Changing Through the Inspector In PlayMode didn't changed her color and I forgot that but now, it's happening even with the Looking. It didn't worked manually too. I need it to work.
I don't know If it's a problem of unity or not but I really want to finish that game and continue using unity for game making and that is very annoying that you make a game and it is working just for the first week and then dies. Please Help Someone. that's very important to me.
( I Wrote The Movement Code and Color code from Tutorials so I'm pretty sure it's not my "beginnery" thing.)
EDIT: Solved It. That was The Animation...
If you need it this is the input code:
private void InputManager()
{
//horizontal moving axis
float hDirection = Input.GetAxis("Horizontal");
//animation speed
anim.speed = 1;
//shift clicking for speeding the character
if (Input.GetKey(KeyCode.LeftShift))
{
//making the moving speed faster
nowMoveSpeed = normalMoveSpeed + fastMoveSpeed;
//making the animation faster
anim.speed = 2;
}
//if the shift is not clicked
else if (!Input.GetKey(KeyCode.LeftShift))
{
//normalizing the moving speed
nowMoveSpeed = normalMoveSpeed;
//normalizing the animation speed
anim.speed = 1;
}
//right movement
if (hDirection > 0)
{
//RigidBody move forcing
rb.velocity = new Vector2(nowMoveSpeed, rb.velocity.y);
//make the character look to the right place
transform.localScale = new Vector2(1, 1);
PlayerName.transform.localScale = new Vector2(0.01384126f, 0.01384126f);
}
//left movement
else if (hDirection < 0)
{
//RigidBody move forcing
rb.velocity = new Vector2(-nowMoveSpeed, rb.velocity.y);
//make the character look to the right place
transform.localScale = new Vector2(-1, 1);
PlayerName.transform.localScale = new Vector2(-0.01384126f, 0.01384126f);
}
else
{
//if not clicking on any key the program needs to do nothing
}
//jumping, and make a jump number limitation
//if the jumping key pressed, and the character is not touching the ground
if (Input.GetButtonDown("Jump") && coll.IsTouchingLayers(ground))
{
Jump();
}
//if the jumping key pressed, and the jump count is less then the accepted jumps in one jump
else if (Input.GetButtonDown("Jump") && jumpCount < jumpNumInAir)
{
Jump();
}
//if the character is just touching the ground
else if (coll.IsTouchingLayers(ground))
{
//jump number will be equal to 0
jumpCount = 0;
}
}
Answer by noamraz · Apr 08, 2020 at 12:14 AM
Just Solved it. The problem was the Animation.. Sorry Unity for judging. You are awesome!