
[ad_1]
combating a wee subject the place if my character walks up a slope he slides again down when at relaxation, and bounces down when working down the slope. I’ve adopted a couple of movies however none appear to deal with the difficulty. I’ve posted my motion code to this point and I’m not against essentially altering this, nevertheless with the opposite points of my recreation, the inflexible physique and collider setup appears to be working fairly properly. Any concepts?
//inputs
if (Input.GetKey(buttonKey["Left"]))
{
inputHorizontal = -1;
}
else if (Input.GetKey(buttonKey["Right"]))
{
inputHorizontal = 1;
}
else
{
inputHorizontal = 0;
}
//leap
if (Input.GetKey(buttonKey["Jump"]) && isgrounded.Grounded && canJump)
{
leap();
leapTimerCurrent = 0;
canJump = false;
}
if (leapTimerCurrent <= leapTimerReset)
{
leapTimerCurrent += Time.fixedDeltaTime;
}
else
{
canJump = true;
}
void FixedUpdate()
{
rb.velocity = new Vector2(inputHorizontal * Time.fixedDeltaTime * runSpeed, rb.velocity.y);
}
void leap()
{
rb.velocity = new Vector2(rb.velocity.x, 0.0f);
rb.AddForce(Vector2.up * leapForce, ForceMode.Force);
}
[ad_2]