I have this code that pushes the player when they collide with the object its attached to either up down left or right depending on the integer. It works fine for the y axis, but it doesn’t move the player on the x-axis
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
other.rigidbody.velocity = new Vector2(xPower, yPower);
}
}
if yPower = 10 or -10 and xPower = 0. It will push the player either up or down. But if xPower = 10 or -10, and yPower = 0 it will not push the player Left/Right. Does anybody know why?