Files
FablishRPG/Assets/Scripts/AnimationEventRelay.cs

62 lines
1.7 KiB
C#
Raw Normal View History

using UnityEngine;
/// <summary>
/// Attach this script directly to the child GameObject that has the Animator component (e.g., "Model").
/// It will catch Animation Events triggered by the animations and forward them up to the parent GameObject
/// where your actual combat scripts (like MeleeCombatLayerController) are sitting!
/// </summary>
public class AnimationEventRelay : MonoBehaviour
{
// ==========================================
// MELEE EVENTS
// ==========================================
public void DealDamage()
{
if (transform.parent != null)
{
transform.parent.SendMessageUpwards("DealDamage", SendMessageOptions.DontRequireReceiver);
}
}
public void Hit()
{
if (transform.parent != null)
{
transform.parent.SendMessageUpwards("Hit", SendMessageOptions.DontRequireReceiver);
}
}
public void loadArrow()
{
if (transform.parent != null)
{
transform.parent.SendMessageUpwards("loadArrow", SendMessageOptions.DontRequireReceiver);
}
}
public void Fire()
{
if (transform.parent != null)
{
transform.parent.SendMessageUpwards("Fire", SendMessageOptions.DontRequireReceiver);
}
}
public void FootR()
{
if (transform.parent != null)
{
transform.parent.SendMessageUpwards("FootR", SendMessageOptions.DontRequireReceiver);
}
}
public void FootL()
{
if (transform.parent != null)
{
transform.parent.SendMessageUpwards("FootL", SendMessageOptions.DontRequireReceiver);
}
}
}