- Home /
How to animate Enemy
I have downloaded a free zombie model with animations.I downloaded it from here . It contains idle,walking, attacking animations in fbx format. I also found a script to follow the player but it does not do any animation, it just follows the player like a ghost. Please help about animating it. Here is the code-
var Distance;
var Target : Transform;
var lookAtDistance = 25.0;
var chaseRange = 15.0;
var moveSpeed = 5.0;
var Damping = 6.0;
var controller : CharacterController;
var gravity : float = 20.0;
private var MoveDirection : Vector3 = Vector3.zero;
function Start ()
{
}
function Update ()
{
Distance = Vector3.Distance(Target.position, transform.position);
if (Distance < lookAtDistance)
{
lookAt();
}
if (Distance > lookAtDistance)
{
}
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 ()
{
GetComponent(NavMeshAgent).destination = Target.position;
}
You will first need to create a animator controller for your Zombie Character idle,walking, attacking. You can check the documentation here http://docs.unity3d.com/$$anonymous$$anual/$$anonymous$$ecanimAnimationSystem.html
Answer by devilsid · Dec 27, 2014 at 04:30 PM
You will first need to create a animator controller for your Zombie Character idle,walking, attacking. You can check the documentation here http://docs.unity3d.com/Manual/MecanimAnimationSystem.html
Your answer
Follow this Question
Related Questions
How to animate a enemy when he is following 0 Answers
Can the animation editor create local rotational data? 3 Answers
Enemy AI Range Detection 3 Answers
Adding animation clips via script 2 Answers