looking to make for a zombie script AI,navmesh or not?

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?

i would suggest against navmesh as zombies are not expected to be smart. and a zombie that can make its way through mazes without even seeing the player wouldn't make sense

2 Answers

2

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

hi

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);
}

Hi deltamish. Your script it is very good and work perfectly. But only on one model of zombie, this script don't work. When the game start, this zombie follow the player but the animation of zombie model rotate model. sorry for my bad english see my video to understand my problem. http://youtu.be/GU6JkzNPpPg What differences are there between navmesh and character controller? Thank you very much for your help.

Hi deltamish. how to Remove rotation from the animation? i have upload the free model (downloaded on the web, it is free) on my google drive Link : https://docs.google.com I'm using Unity 4 from a few months and my projects work perfectly, and i don t use realtime reflection. Thank you very much for your help!!

hi i got the files i will try to fix it now and by the way did you create all that animation and textures Really nice

hi found out the problem the problem was the forward of the model is actually right of the model that means the front(facial) part of the model is not forward(blue coloured arrow) in its local or world axis its is right(red color arrow) so all you have to do is create a new empty gameobject and rotate in such a way that the facial part of the model and the forward(blue arrow) of the empty gameobject face same direction then make the zombie object child of empty object and if you want even more realistic animation(animation spedd very very important) just lerp from 0 to speed and divide

Hi deltamish. I have solved my problem with your advice. I had already tried to solve with a empty gameobject, but i don t have rotate model. Now in my app I have another zombie =). Thank you very much for your help. Great man.