EDIT: Found the problem.
Hi guys,
I’m following a tutorial to make a simple platformer. Now in the tutorial we’ve made the character and an object.
If the character touches the object, he get’s thrown in the air (y-axis only).
I’ve tried to change the x-axis expecting the character would’ve get thrown to the left or right also.
But unfortunately the character keeps getting thrown in the y-axis only.
void pushBack(Transform pushedObject)
{
Vector2 pushDirection = new Vector2(0, 1).normalized; // I changed the x value to 1 aswell.
pushDirection *= pushBackForce;
Rigidbody2D pushRB = pushedObject.gameObject.GetComponent<Rigidbody2D>();
pushRB.velocity = Vector2.zero;
pushRB.AddForce(pushDirection, ForceMode2D.Impulse);
}
Can someone tell me what I’m doing wrong?