A New Way to Move Around (It's a SOLUTION)

I was trying to make a 2d game before begin this section eventually I end up with a misery but learnt so much. While I writing the code about movement I used add force instead of velocity so I get a better result on ramps or objects I push. Here’s the code for you.

float horizontalAxis = Input.GetAxis("Horizontal");
float verticalAxis = Input.GetAxis("Vertical");

if(rbVelocity.magnitude<speedLimit)
{
	playerRB.AddForce(new Vector2(horizontalAxis*speed,0));
}

if(Input.GetAxis("Vertical")!=0 && isLanded && !onLadder)
{
	playerRB.AddForce(Vector2.up*jumpMultiplier);
	isLanded=false;
}
1 Like

Privacy & Terms