public static Vector3 GetKnockbackDir(LungeDir dir, Transform origin, Transform target, bool planar) { Vector3 a = Vector3.zero; switch (dir) { case LungeDir.Forward: a = origin.forward; break; case LungeDir.Backward: a = -origin.forward; break; case LungeDir.Side: a = origin.transform.right * Mathfx.RandomOneOneminus(); break; case LungeDir.Target: if (target) { a = target.position - origin.position; } else { a = origin.forward; } break; default: a = origin.forward; break; } if (planar) { a = Vector3.ProjectOnPlane(a, Vector3.up); } return(a.normalized); }