Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// This gets us an axis around which to spin, in the target bone's space, that is perpendicular to the direction of the incoming damage.
- /// We use it for jiggle calculations, spinning backflips, etc.
- /// </summary>
- /// <param name="damagingHit">the incoming hit/damage we want to be perpendicular to</param>
- /// <param name="targetBone">the bone (transform space) in which to generate the perp spin axis</param>
- /// <returns></returns>
- protected Vector3 GetPerpSpinAxis(HitboxFistState damagingHit, Transform targetBone)
- {
- // Get as precise an attacker origin as we can get.
- Vector3 damageOrigin = gameObject.transform.position;
- if (damagingHit.TargetFist != null)
- {
- Quaternion tempRot = Quaternion.identity; // (unused, since we don't care about a local orientation here)
- damagingHit.CalcRelativeHitboxTransforms(damagingHit.forceOffset, Quaternion.identity, ref damageOrigin, ref tempRot);
- }
- else if (damagingHit.parentObject != null)
- {
- // @TODO: Maybe make another version of this method that just lets us specify this, for getting a perp axis without incoming damage
- damageOrigin = damagingHit.parentObject.transform.position;
- }
- // We want to generate a right-vector here, so that positive rotation is always "away" from attacker.
- Vector3 fromAttacker = targetBone.position - damageOrigin;
- fromAttacker.y = 0.0f;
- // (if we're too far above/below the attacker, we just default to our own right)
- Vector3 perpAxis = gameObject.transform.right;
- if (fromAttacker.magnitude > 0.1f)
- {
- perpAxis = Vector3.Cross(Vector3.up, fromAttacker.normalized);
- perpAxis = targetBone.worldToLocalMatrix * perpAxis;
- perpAxis.Normalize();
- }
- return perpAxis;
- }
Advertisement
Add Comment
Please, Sign In to add comment