FreshRSS

Normální zobrazení

Jsou dostupné nové články, klikněte pro obnovení stránky.
PředevčíremHlavní kanál
  • ✇Recent Questions - Game Development Stack Exchange
  • How to stop the slide on slopes?Sam Law
    I'm struggling with a wee issue where if my character walks up a slope he slides back down when at rest, and bounces down when running down the slope. I've followed a few videos but none seem to address the issue. I've posted my movement code so far and I'm not opposed to fundamentally changing this, however with the other aspects of my game, the rigid body and collider setup seems to be working quite well. Any ideas? //inputs if (Input.GetKey(buttonKey["Left"])) { inputHorizont
     

How to stop the slide on slopes?

I'm struggling with a wee issue where if my character walks up a slope he slides back down when at rest, and bounces down when running down the slope. I've followed a few videos but none seem to address the issue. I've posted my movement code so far and I'm not opposed to fundamentally changing this, however with the other aspects of my game, the rigid body and collider setup seems to be working quite well. Any ideas?

 //inputs
    if (Input.GetKey(buttonKey["Left"]))
    {
        inputHorizontal = -1;
    }
    else if (Input.GetKey(buttonKey["Right"]))
    {
        inputHorizontal = 1;
    }
    else
    {
        inputHorizontal = 0;
    }

    //jump
    if (Input.GetKey(buttonKey["Jump"]) && isgrounded.Grounded && canJump)
    {
        jump();
        jumpTimerCurrent = 0;
        canJump = false;
    }

    if (jumpTimerCurrent <= jumpTimerReset)
    {
        jumpTimerCurrent += Time.fixedDeltaTime;
    }
    else
    {
        canJump = true;
    }

 void FixedUpdate()
{
    rb.velocity = new Vector2(inputHorizontal * Time.fixedDeltaTime * runSpeed, rb.velocity.y);
}

    void jump()
{
    rb.velocity = new Vector2(rb.velocity.x, 0.0f);
    rb.AddForce(Vector2.up * jumpForce, ForceMode.Force);
}
❌
❌