Hello guys, I have a problem with my game, basically I can't make my player jump left or right just up. I would like it to jump up+left when pressing the left side of the screen and right+up when pressing the right one. Here is my script which doesn't work : rigidbody = GetComponent<Rigidbody2D>(); rigidbody.velocity = new Vector3(100f,0f, 0f); rigidbody.AddForce(new Vector3(0, 10, 0) , ForceMode2D.Impulse); player.GetComponent<Animator>().enabled = false; player.GetComponent<Rigidbody2D>().gravityScale = 10f; THANK YOU GUYS!
You're explicitly setting the velocity every frame, which overrides anything else you've set. Keep the current y velocity when you set the value and everything should work: Code (csharp): rigidbody.velocity = new Vector3(100f, rigidbody.velocity.y, 0f); Also, for future posts use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/