Code to make player visible to AI?

I know this is a little complex and I’m only a beginner with javascript, but I’m beginning to make an AI and im using the Bootcamp Demo to make my first project with AI. So how can I make an AI that can tell if the player is more then 70% behind cover or if he is crouched in grass? And make it respond to gunfire?

To be honest I’m a little puzzled on making anything with an AI, so help would be appreciated.

Look into Raycasting, that should get you started… ray cast to see if the player is in front of the enemy or not

thanks, and besides that, any way to change your picture on forums?

Yeah, this link should do the trick for you http://forum.unity3d.com/profile.php?do=editavatar

Thank you again!

Also, on a completely unrelated note. Rather then make a new page I have a question regarding AI.

I’m using the Bootcamp Demo to make a game, don’t worry It’s heavily altered and going to be free, I have morals too you know…

However I’m keeping the character and animations, so using those, how would I make a basic AI that shoots on sight? I’ll make my own script to have him walk a path along my map.

Is the bullet already scripted in the demo? And is damage and inflicted damage already there?
Also, could I just duplicate the soldier to make the enemy? Or would that mess things up?

Please Any Examples would be great, my only knowledge is after reading the unity essentials book and doing a little research.
I know I’m getting a little ahead of myself but I have a good Idea a want to follow up on. Thanks.

Player.EnemyAI.SetVisible = true;

What does that do? I’m pretty sure making an enemy AI is a complex thing to do. RIght?

I’m just teasing. Why dont you start out a bit simpler. For example in the Update method check the distance between the enemy and the player. You could also compare the angle between the two entities and if its within a certain FOV angle then the player is seen.

To test if theres objects in the way then you’ll half to do the above checks first and if they hold true then fire a ray at the enemy player. If the enemy player comes back as being hit by the ray then you know the enemy is seen by the player.

ok thanks