Question by
NeGoBarai99 · Dec 11, 2015 at 06:26 PM ·
animation
Why am I getting "MissingMethodException" ?
I Was trying to call an animation but it showed that error. It says that the problem is coming from the part of the code "calling the animation" i hope someone can help.
var Distance;
var Target : Transform;
var lookAtDistance = 25.0;
var chaseRange = 25;
var attackRange = 1.5;
var moveSpeed = 5.0;
var Damping = 6.0;
var AttackRepeatTime = 1;
var theDamage = 25;
var clip : AnimationClip;
private var attackTime : float;
private var attackNow = true;
var controller : CharacterController;
var gravity : float = 20.0;
private var MoveDirection : Vector3 = Vector3.zero;
function Start ()
{
attackTime = Time.time;
}
function Update ()
{
Distance = Vector3.Distance (Target.position, transform.position);
if (Distance < lookAtDistance)
{
lookAt();
}
if (Distance < attackRange)
{
attack ();
}
else if (Distance < chaseRange)
{
chase();
}
}
function lookAt()
{
var rotation = Quaternion.LookRotation(Target.position - transform.position );
transform.rotation = Quaternion.Slerp(transform.rotation,rotation, Time.deltaTime * Damping);
}
function chase()
{
moveDirection = transform.forward;
moveDirection *= moveSpeed;
moveDirection.y -= gravity * Time.deltaTime ;
controller.Move(moveDirection * Time.deltaTime);
GetComponent.clip().Play(clip.name);
}
function attack()
{
if (Time.time > attackTime)
{
Target.SendMessage("DamageYourAss", theDamage);
Debug.Log("Insert attack here");
attackTime = Time.time + AttackRepeatTime;
}
}
Comment
Answer by Jessespike · Dec 11, 2015 at 08:22 PM
This line makes no sense:
GetComponent.clip().Play(clip.name);
Did you mean to do this?
GetComponent(Animation).Play(clip.name);