Batch 1 - Scripts

This commit is contained in:
Rohan
2026-07-21 08:58:18 +05:30
parent 604c0c786a
commit 1dcd8bf80b
41 changed files with 655 additions and 13 deletions

View File

@@ -0,0 +1,47 @@
using System.Collections;
using UnityEngine;
public class CharacterCombat : MonoBehaviour, IDamageReceiver
{
private Animator animator;
void Awake()
{
animator = GetComponentInChildren<Animator>();
}
public void OnDamageTaken(string bodyPart)
{
switch (bodyPart)
{
case "Head":
animator.SetTrigger("HitHead");
break;
case "Body":
animator.SetTrigger("HitBody");
break;
case "Legs":
StartCoroutine(KnockdownRoutine());
break;
}
}
IEnumerator KnockdownRoutine()
{
// Step 1: play leg hit
animator.SetTrigger("HitLegs");
// wait for hit animation
yield return new WaitForSeconds(0.6f);
// Step 2: fall happens automatically via Exit Time
// stay on ground
yield return new WaitForSeconds(2f);
// Step 3: stand up
animator.SetTrigger("StandUp");
}
}