How do i make an ai shoot? 2D
Hey im making a 2D game and im trying to set up a basic ai. This game is an isometric view kinda like the game "Realm of the Mad God". I do not know how to make an enemy shoot at a player so i was wondering if anyone could tell me or get me on the right direction on figuring this out.
Answer by Cuttlas-U · Apr 17, 2017 at 06:55 AM
hi; i tell u the simple way : 1- u create some kind of fire projectiles in your game ( it can be a small cube that has a collider ); 2 - u attach a script to this bullut so it can move forward and reduse health on impact to other player;
3 - then u need to make a prefab of it ; 4 - u should learn Instantiation and every time player do fire Instantiation another of this prefab;
so wich part of these u have problem tell me so i can help u ;
ok i havent finished it yet but how would i make it shoot at the player? all this would do is shoot when i click. i want it to find the player then shoot at it. i already have the ai moving to the player.
hi; if u make your ai to look at his opponent ( for example by "transform.lookAt(Player);
every time he shoot it will hit on player;
Your answer
![](https://koobas.hobune.stream/wayback/20220612120006im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Turning player toward enemy after bool is true/button is pressed 1 Answer
My 2d Unity character won't jump.,2D Unity sprite not jumping 0 Answers
Problems disabling an AI and giving control to the Player 0 Answers
Script to enable Firing 1 Answer
How can i move a 2d player in a 3d scene in x and z axis? maybe with a canvas joystick? 1 Answer