Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- namespace SpartanFist
- {
- /// <summary>
- /// This is a twiddler that is activated by punching - but you MUST punch it from the front, while facing it, and the punch must come from some actual parent-object.
- /// </summary>
- public class TwiddlerPunchable : Twiddler
- {
- /// <summary>
- /// Indicates we've been hit by something, and should probably be offended
- /// </summary>
- /// <param name="hitState">the stats wot hit us</param>
- public void FistHit(HitboxFistState hitState)
- {
- if (hitState.parentObject == null) { return; } // (it takes an actual person to hit us)
- float headingDot = Vector3.Dot(hitState.parentObject.transform.forward, gameObject.transform.forward);
- if (headingDot > 0.0f) { return; } // ... and they have to be facing us...
- headingDot = Vector3.Dot(hitState.parentObject.transform.position - gameObject.transform.position, gameObject.transform.forward);
- if (headingDot < 0.0f) { return; } // ... and they ALSO need to be in front of us, not hitting from the side or rear.
- // Otherwise, cool, we got punched! So we twiddle...
- bool hitRegistered = Twiddle(!toTwiddle.SwitchState);
- // ... and we let the hitter know if they successfully hit something. If we can't twiddle in that direction, they should probably get a <TANG!> kind of hit like they would if they hit an armored guy.
- hitState.HitResponse(this.gameObject, hitRegistered ? -1.0f : 0.0f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment