I was trying to make a dash code for my player but for some reason when I dash all the other Rigidbodies seem to float up. Is there a way to let the Physics2D.gravity to only affect my player?
void Update()
{
if(Input.GetMouseButtonDown(0) && canDash == true)
{
if(Input.GetAxis(“Horizontal”) < 0)
{
rb2d.velocity = Vector2.left * 15;
Physics2D.gravity = new Vector2(0f,5f);
Invoke(“stopDashing”, 0.1f);
canDash = false;
}
else if(Input.GetAxis(“Horizontal”) > 0)
{
rb2d.velocity = Vector2.right * 15;
Physics2D.gravity = new Vector2(0f,5f);
Invoke(“stopDashing”, 0.1f);
canDash = false;
}
}
}