Whenever my player is attacked by an enemy I want him to be knocked in the direction away from the enemy. Instead he always get’s knocked the way he isn’t facing.
This is the part of the script which controls the knockback:
if (other.gameObject.name == "enemySword" && !damaged){
var target : Transform = other.transform;
health -= 10;
dir1 = transform.position - target.position.normalized;
rb.AddRelativeForce(dir1 * thrust);
damaged = true;
damageWait();
}
}
I tried that earlier and the character no longer gets knocked back at all.
– imaethan