
CROW
Project Type
Software
Role
University/Group
Unity
All Design, All Programming
Iterative Design: Parry
Players didn’t understand MVP version of Parry
First Attempt: Throwing it in their Face
They Dodged
Failure:
Boring
Didn't work
Even when players parried, they weren't having much fun.
NPC Trainer
Satisfying!
Enemy Design/Encounters now demand Parrying
Programming: Hit Detection
/// <summary> /// Performs a box sweep each frame. Each sweep creates a permanent line segment if distance > threshold. /// If the distance is below the threshold, all previously created lines revert to green. /// </summary> private void CheckMeleeCollisions() { Vector3 currentPosition = transform.position; Quaternion currentRotation = transform.rotation; Vector3 movement = currentPosition - previousPosition; float distance = movement.magnitude; Quaternion midpointRotation = Quaternion.Slerp(previousRotation, currentRotation, 0.5f); for (int i = 0; i < weaponColliders.Count; i++) { var boxCol = weaponColliders[i]; if (boxCol == null) continue; Vector3 halfExtents = Vector3.Scale(boxCol.size * 0.5f, transform.lossyScale); Vector3 worldCenterPrev = previousPosition + previousRotation * boxCol.center; Vector3 worldCenterNow = currentPosition + currentRotation * boxCol.center; Vector3 castDirection = (worldCenterNow - worldCenterPrev).normalized; bool hitOccurred = false; Vector3 firstHitPoint = Vector3.zero; RaycastHit[] hits = Physics.BoxCastAll( worldCenterPrev, halfExtents, castDirection, midpointRotation, distance, hitMask, QueryTriggerInteraction.Ignore ); if (hits.Length > 0) { hitOccurred = true; System.Array.Sort(hits, (h1, h2) => h1.distance.CompareTo(h2.distance)); firstHitPoint = hits[0].point; foreach (var hit in hits) { if (hit.collider && hit.collider.gameObject != boxCol.gameObject) { Debug.Log("Hit: " + hit.collider.name); } } } } } }