Tried using these (not together) in the OnTriggerEnterCollider2D, both work only on the y axis, not on the x. What am I doing wrong?
Vector2 directionVector = other.transform.position - transform.position;
Rigidbody2D body = other.GetComponent<Rigidbody2D>();
if (body != null)
{
float forceMagnitude = 0.8f;
ForceMode2D mode = ForceMode2D.Impulse;
body.AddForce(directionVector * forceMagnitude, mode);
}
Vector3 direction = (other.transform.position - transform.position).normalized;
body = other.GetComponent<Rigidbody2D>();
body.AddForce(direction * 10);