#pragma strict
public class AttackBehaviour extends StateMachineBehaviour {
public var particle: GameObject;
public var radius: float;
public var power: float;
protected var clone: GameObject;
public override function OnStateEnter(animator: Animator, stateInfo: AnimatorStateInfo, layerIndex: int) {
clone = Instantiate(particle, animator.rootPosition, Quaternion.identity) as GameObject;
var rb: Rigidbody = clone.GetComponent.<Rigidbody>();
rb.AddExplosionForce(power, animator.rootPosition, radius, 3.0f);
}
public override function OnStateExit(animator: Animator, stateInfo: AnimatorStateInfo, layerIndex: int) {
Destroy(clone);
}
public override function OnStateUpdate(animator: Animator, stateInfo: AnimatorStateInfo, layerIndex: int) {
Debug.Log("On Attack Update ");
}
public override function OnStateMove(animator: Animator, stateInfo: AnimatorStateInfo, layerIndex: int) {
Debug.Log("On Attack Move ");
}
public override function OnStateIK(animator: Animator, stateInfo: AnimatorStateInfo, layerIndex: int) {
Debug.Log("On Attack IK ");
}
}
using UnityEngine;
public class AttackBehaviour : StateMachineBehaviour
{
public GameObject particle;
public float radius;
public float power;
protected GameObject clone;
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
clone = Instantiate(particle, animator.rootPosition, Quaternion.identity) as GameObject;
Rigidbody rb = clone.GetComponent<Rigidbody>();
rb.AddExplosionForce(power, animator.rootPosition, radius, 3.0f);
}
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Destroy(clone);
}
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Log("On Attack Update ");
}
override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Log("On Attack Move ");
}
override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Log("On Attack IK ");
}
}