Hi i m looking to make a simple zombie script AI.
The enemy should follow “player” and when the distance of player and enemy is near, this attack changing the animation
To make a good zombie script i need a navmesh agent or not?
can you help me with a simple start code?
If You are beginner believe me brother AI is most worst thing is game Development , no one here will help you with this stuff … You Search for Term A algorithm and get started but i will prefer to you to use a plugin known as “RAIN AI” Best part of plugin is its free and it support zombies comes with video tutorials by both RAIN and Tornado Twins*
Cheers
here is the Link
RAIN AI : http://rivaltheory.com/tag/rain-ai
Grab your free copy now … !!!
Happy AI
here is a simple AI code that moves th character without using character controller or Navmesh
Edit
#pragma strict
var Attackdist:float = 5;
var Player:Transform;
var MoveAnim:AnimationClip;
var AttackAnim:AnimationClip;
var speed:float;
var damage:float = 5;
var model:Transform;
private var _me:Transform;///this the character
private var tempspeed:float;
function Start(){
tempspeed = speed;
if(!_me)
_me = transform;//cache for better performance
model.animation[MoveAnim.name].wrapMode = WrapMode.Loop;
model.animation[AttackAnim.name].wrapMode = WrapMode.Once;
}
function Update(){
//transform.LookAt(Player);
_me.rotation = Quaternion.Slerp(_me.rotation,Quaternion.LookRotation(Player.position - _me.position),Time.deltaTime * 9);
_me.eulerAngles = Vector3(0,_me.eulerAngles.y,0);
var fwd:Vector3 = _me.TransformDirection(0,0,1);
transform.position += fwd*speed*Time.deltaTime;
model.animation.Play(MoveAnim.name);
if(Vector3.Distance(_me.position,Player.position) <=Attackdist){
speed = 0;
Attack();
}else{
model.animation[AttackAnim.name].layer = -1;///add this if not it will not play move anim
speed = tempspeed; //initial speed
}
}
function Attack(){
//yield WaitForSeconds(0.5);//wait 0.5 seconds before playing anim
if(!model.animation.IsPlaying(AttackAnim.name))
model.animation[AttackAnim.name].layer = 1;//add this if not it will not play attack animation
model.animation.Play(AttackAnim.name);
Player.SendMessage("TakeDamage",damage,SendMessageOptions.DontRequireReceiver);
}