I’m trying to get my character to be knocked back by attacks from enemies.
At the moment I have this:
rigidbody2D.velocity = new Vector2 (0, 0);
GetComponent<MovementScript> ().enabled = false;
Vector3 EnemyDirection = ((transform.position.x - enemy.position.x)>0?rightvec:leftvec) + (Vector3.up);
this.rigidbody2D.velocity = (EnemyDirection * force);
Debug.Log (EnemyDirection);
MyHealth--;
GetComponent<MovementScript> ().enabled = true;
However my character goes straight up rather being knocked into a direction. Any suggestion why this might be?
Any help is much appreciated, thanks.