Skip to main content
fixed typos, added markdown to code & keypresses, left aligned code
Source Link
Pikalek
  • 12.5k
  • 5
  • 45
  • 52

I've spent hours trying to find the problem with this:

        if (Input.GetKeyDown(KeyCode.Q))
    {
        playerController.rb.AddForce(new Vector2(-forceAmount, 0), ForceMode2D.Impulse);
    }
    if (Input.GetKeyDown(KeyCode.E))
    {
        playerController.rb.AddForce(new Vector2(0, forceAmount), ForceMode2D.Impulse);
    }

When I press EE force is applied upwards normally, but when I press QQ nothing happens.

I checked the rigidbodyrigidbody and the physics material, and the issue doesn't come from those because I changed the MassMass and the Gravity ScaleGravity Scale of the player, changed the friction of the PhysicsMaterial2DPhysicsMaterial2D to 0 and non 0, and applyedapplied force while the player is in the air, but nonnone of them worked.

I've spent hours trying to find the problem with this

        if (Input.GetKeyDown(KeyCode.Q))
    {
        playerController.rb.AddForce(new Vector2(-forceAmount, 0), ForceMode2D.Impulse);
    }
    if (Input.GetKeyDown(KeyCode.E))
    {
        playerController.rb.AddForce(new Vector2(0, forceAmount), ForceMode2D.Impulse);
    }

When I press E force is applied upwards normally, but when I press Q nothing happens.

I checked the rigidbody and the physics material, and the issue doesn't come from those because I changed the Mass and the Gravity Scale of the player, changed the friction of the PhysicsMaterial2D to 0 and non 0, and applyed force while the player is in the air, but non of them worked.

I've spent hours trying to find the problem with this:

if (Input.GetKeyDown(KeyCode.Q))
{
    playerController.rb.AddForce(new Vector2(-forceAmount, 0), ForceMode2D.Impulse);
}
if (Input.GetKeyDown(KeyCode.E))
{
    playerController.rb.AddForce(new Vector2(0, forceAmount), ForceMode2D.Impulse);
}

When I press E force is applied upwards normally, but when I press Q nothing happens.

I checked the rigidbody and the physics material, and the issue doesn't come from those because I changed the Mass and the Gravity Scale of the player, changed the friction of the PhysicsMaterial2D to 0 and non 0, and applied force while the player is in the air, but none of them worked.

Source Link

ForceMode2D.Impulse not appliying force to the sides

I've spent hours trying to find the problem with this

        if (Input.GetKeyDown(KeyCode.Q))
    {
        playerController.rb.AddForce(new Vector2(-forceAmount, 0), ForceMode2D.Impulse);
    }
    if (Input.GetKeyDown(KeyCode.E))
    {
        playerController.rb.AddForce(new Vector2(0, forceAmount), ForceMode2D.Impulse);
    }

When I press E force is applied upwards normally, but when I press Q nothing happens.

I checked the rigidbody and the physics material, and the issue doesn't come from those because I changed the Mass and the Gravity Scale of the player, changed the friction of the PhysicsMaterial2D to 0 and non 0, and applyed force while the player is in the air, but non of them worked.