- Home /
how to make Enemy Ai aircraft shoot at me
can somebody help me, im making a dogfighting game but cannot find or make script for the Enemy to fire at me, i already got the basics like him following me and colision n stuff if someone could help i would really appreciate it
you have to decide what he fires to you with, whether it is some rigidbody ballistics, or some lasers made from long cubes without collision, so basically you're just looking for simple Cannonball, laserbeam, bullet, firing scripts, and making him shooting you literally a few lines like-
if enemy/player distance smaller than 500 m AND enemy relative rotation to player smaller than 10 angles, activate enemy shooting.
the difficult part is the 2nd, you have to find the correct function for relative angle between 2 objects https://www.google.fr/search?q=unity+relative+angle+between+2+objects&oq=unity+relative+angle+between+2+objects&aqs=chrome..69i57j69i65j69i60l4.1390j0&sourceid=chrome&espv=2&es_sm=93&ie=UTF-8
start by making the enemy shoot constantly, and then try and learn to make for lines of conditions from position and angle
Now that is the problem because i have no idea how to make enemy ai shoot at me even constatly i made the ai shot but the bullets just stood still
Answer by getyour411 · Sep 21, 2013 at 03:37 AM
Take this for an example:
http://forum.unity3d.com/threads/117252-Creating-Flying-AI-%28Planes-starships-etc-%29