Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do I add shooting enemy AI in Unity 3d?

JeetJeet Member
edited June 29 in Programming

Hi I am new to unity and if you know how to add shooting enemy AI in unity 3d please help me out!!!

Any Help will be appreciated!!


Best Answer

  • Sugar_SnailSugar_Snail Member
    Accepted Answer

    in the update function you can do

    Collider collide = Physics.OverlapSphere(enemy.position, sphereSize, whatIsPlayer);

    if(collide = null) //if the player isnt in it's 'bubble'


    InvokeRepeating("Shoot", 2f, shootRate);

    transform.LookAt(player.position, vector3.up);

    } else



    transform.LookAt(-player.position, vector3.up);


    in the else you can make it run away


Sign In or Register to comment.