unity 3d enemy that shoots at you and gets killed

how do i make an enemy shoot at the player and if the player shoots at it. it'll die within 20 bullets.

go check the fps tutorial. it already features such a simple AI, modify health and bullet damage values to get to your 20 hits.

http://unity3d.com/support/resources/tutorials/fpstutorial.html

In basic it is pretty easy.

First you will need to make the script that stores the health and can be accessed by another scripts, so:

Add this to the enemy and name the script enemyHealth:

  static var health = 100; //Or any other value.

//The you want to declare when the character dies and what will happen if he dose:

    function Update ()
    {
        if(health <= 0)
        {
        // Let the character die
        }
    }

Then we would want to create a new script that hurts the enemy:

Put this on the camera:

var hit : RaycastHit;
var damage = 10;

function Update ()
{
Physics.Raycast(transform.position, transform.forward, hit, Mathf.Infinity);

if(hit.collider.tag == "enemy" && Input.GetButtonDown("Fire1")) //Add a tag to the player that is named "enemy"
    {
    enemyHealth.health -= damage;
    }
}

This is untested so there may be errors.

I am having this same type of issue and the fps tutorial sounds like it no longer works with the new unity. Is there somewhere else to try and look? Or if someone is just willing to listen to my new issue and help me out that would be cool too.

For the enemy health just put Var Enemy health = 10;

for the enemyHealth just put (var enemyHealth = 10;