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.
AddForce
that limits the directions it acts in - that would have been discovered long ago by thousands of developers if it were the case. So it has to be something else in your project causing it. Try duplicating your project and strip away everything you can while preserving this glitch. This will help you make a Minimal Complete Verifiable Example: the smallest set of code and scene setup that contributes to it. \$\endgroup\$