- Home /
How to make Enemy shoot at Player Top Down
Anybody that could help me in the right direction? been searching for a while for a way to make a top down enemy shoot in the direction of the player and rotate the bullet prefab, also need a timer to selfdestruct, but i can probably find that out myself, i am really bad at everything with ai and stuff, may need some range thing to if its not to hard
Answer by Cornelis-de-Jager · Nov 17, 2019 at 09:45 PM
You are not going to get answers here. Honestly i just google "Unity 3D Top Down Shooter Tutorial" and found a bunch of videos.
This is how you will get better.
1. Choose a Genre
2. Choose 2D or 3D
3. Google "Unity [2D/3D] [genre chosen] tutorial"
4. Click on videos
5. Follow the tutorial.
Don't even think about making your own game before you've done 3-5 of these tutorials or you will just simply fail. If you can't complete any of the tutorials you won't be able to complete your own game.
if you were able to complete the tutorials then you'll have a good idea of how it should be made.
i have cosen a genre(rougelite), 2d and followed a lot of tutorials i have a player with a basic attack and an enemy with animations but i just cant figure out how to make it shoot exactly like i want, there are not a lot of videos on exacly what i need.
comon man, i have made it spawn now i need to make it rotate towards target at start and give it a velocity
I doubt you put in any effort man. I literally just copied " rotate towards target" from your sentence above, pasted it into google and it came of with The Rotate towards function.
https://docs.unity3d.com/ScriptReference/Vector3.RotateTowards.html
Which sounds exactly like what you are looking for.
You have probably not found what i said i needed, everything i have found is weird or dosent work or almost works. i need it to rotate but not like the look at cause that makes it look at it all the time even if i put it in start, it also rotates in z direction which is horible and also ruins the collider, and then theres the other thing that is to confusing and dosent work for multiple reasons, one is that i cant get the position of the target from a script inside a prefab, cant you just help me?
private void Start()
{
Vector3 temp = new Vector3(0, 0, -2.988281f);
transform.position = new Vector3(transform.position.x, transform.position.y, 0);
var dir = target.position - transform.position;
var angle = $$anonymous$$athf.Atan2(dir.y, dir.x) * $$anonymous$$athf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle -= 80, Vector3.forward);
rb.AddForce(new Vector2(10, 10), Force$$anonymous$$ode2D.Impulse);
}
Follow this Question
Related Questions
How to create a simple Enemy AI for a 2D game? Mine isn't working. . . 1 Answer
Top down 2d shooting - XZ rotation 0 Answers
2D Top Down Shooter Shooting Problems 1 Answer
shooting in 2d problem 0 Answers
Only one bullet AI works? 0 Answers