2D Enemy Shooting Unity Tutorial

  Рет қаралды 62,631

MoreBBlakeyyy

MoreBBlakeyyy

Күн бұрын

Пікірлер: 107
@ElateTugboat
@ElateTugboat 8 ай бұрын
I love the explanations for each thing you add, very nice tutorial!
@A_Name-tl6uq
@A_Name-tl6uq 7 ай бұрын
To some who's bullets also dont follow the players movements check that the rigid body in code (the variable declared as rb) is the same as your character uses. For example mine was RigidBody2D so I had to alter the code to be rb = GetComponent(); rather than rb = GetComponent();
@reyhanramadhan9862
@reyhanramadhan9862 2 ай бұрын
THANK U SO MUCH DUDE. I TOOK ME 6 HOURS to figuring why my projectile wont move. Such a lifesaver my guy
@Skywalker_Jedi_Master
@Skywalker_Jedi_Master Жыл бұрын
One of the best enemy tutorials, thanks
@SilasRobinson
@SilasRobinson 2 жыл бұрын
Awesome! Works like a charm!! :)
@jamesbarker1994
@jamesbarker1994 9 ай бұрын
The rotation of the bullet has saved my ass! thank you sir thumbs uppp
@hipunpun
@hipunpun 11 ай бұрын
Very helpful, thank you very much.
@pickard1988
@pickard1988 Жыл бұрын
great tutorial, nice and simple, thank you 👌
@DinosaurFalcon
@DinosaurFalcon 2 жыл бұрын
Really nice thanks so much !
@aryanugraha4289
@aryanugraha4289 2 ай бұрын
thank you sir, this tutorial really help me
@its_homayoun
@its_homayoun Жыл бұрын
it was a good video. thanks for helping me If I hadn't seen this video , the way that I used to detect player at a range was triggering the player with some collider😂
@CodeKokeshi
@CodeKokeshi Жыл бұрын
great, I managed to make a homing projectile ( a shuriken that I've animated in piskel so the tutorial about the rotation was not used because the shuriken is already spinning), but instead of the enemy, it was the player doing it, foreach and length to calculate the nearest target so I can have multiple targets
@allaboutpaw9396
@allaboutpaw9396 Жыл бұрын
Great Tutorial, I am happy it works... The maths are not my strong point after all :P
@bigbob_yt
@bigbob_yt 8 ай бұрын
Saved my game, i subbed
@humanoterra4770
@humanoterra4770 Жыл бұрын
Thank you very much, it helped me a lot.
@Kiiwinho
@Kiiwinho 2 жыл бұрын
Thank you so much
@venomradar
@venomradar 2 жыл бұрын
i have a problem where the game freezes when the player dies and said the object is not set to an instance
@barryeren
@barryeren 9 ай бұрын
Hello this video is really saved me hours thank you for the tutorial. I have a one simple question, in around 9:30 you use distance for shooting the player when it was near, I used collision box 2d and works the same but I really wanted to know which one is better for performance?
@ephraimgaming766
@ephraimgaming766 Жыл бұрын
tip if your bullet isn't shooting at the position you want it to shoot it at drag the bulletpos to the rifle (this is shown in the vid but I'm saying this in case people missed)
@alvarowwrvl
@alvarowwrvl Жыл бұрын
nice, very helpful
@Rayoski321
@Rayoski321 5 ай бұрын
the best tutorials
@Quadinian
@Quadinian 2 жыл бұрын
Thanks for this video
@alvinnep465
@alvinnep465 Жыл бұрын
I got this error " Missing Reference Exception: the object of type 'GameObject' has been destroyed but you're still trying to access it" and my bullet didn't spawn.
@paulsanchez9900
@paulsanchez9900 Жыл бұрын
Do you happen to find the solution?
@lolerishype
@lolerishype Жыл бұрын
I don't know why at the start even though I am outside of its detection range, IT STILL HITS ME WITH ONE, SINGLE BULLET. Then, everything works normally.
@lolerishype
@lolerishype Жыл бұрын
Fixed the problem! REMEMBER TO DELETE THAT SPRITE FROM THE HIEARCHY!
@simonstechhacks
@simonstechhacks Жыл бұрын
@@lolerishype It said that in the video :|
@aapris1986
@aapris1986 2 жыл бұрын
Hallo! Great video! Where can I find the video how to create this from scratch and also download assets?
@lehmspielt
@lehmspielt 2 жыл бұрын
Can you make a video on 2d enemy ai? Not top down like you did before
@boo24ndb
@boo24ndb Жыл бұрын
very helpfull😀
@nimbusz260
@nimbusz260 2 жыл бұрын
I have problem I did what you tell but only the rotation doesn't work for me
@naruto40kiba30
@naruto40kiba30 Жыл бұрын
I’m having a problem where it says “the name ‘transform’ does not exist in the current context”
@alexisislas-gonzalez5991
@alexisislas-gonzalez5991 Жыл бұрын
Advice or syntax for this with a 3D object and with coroutine.
@RockstarKaboomGaming
@RockstarKaboomGaming 8 ай бұрын
I followed the tutorial step by step but the enemy is shooting bullets towards the foot of the player. Could someone tell me what is going wrong?
@firewarrior8298
@firewarrior8298 8 ай бұрын
What should I do if I want to make the enemy only shoot forward?
@joshuaberketa7986
@joshuaberketa7986 11 ай бұрын
Is There a way that when you die you respawn when the bullet hits you and your health is 0??!
@sumittiwari9272
@sumittiwari9272 Жыл бұрын
Projectile is not visible in game view and it's z value is automatically set to -19.8 while is being spawned pls help
@Peter22055
@Peter22055 Жыл бұрын
Do you know a simple script so the enemy will rotate towards the player?
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
Basecaly, all you have to do is check if the player transform.x is greater or lower then the enemy transform.x. If the player transform .x is greater than enemy transform.x, set the enemy sprite.flipx to false, if its lower, to true. Hope this helps.
@polskigamer2643
@polskigamer2643 Жыл бұрын
I have the problem with the bullet, when it collides with the player it doesnt destroy, it flies by the player
@RockstarKaboomGaming
@RockstarKaboomGaming 8 ай бұрын
add rigidbody2d to the bullet and even player
@chenpead
@chenpead Жыл бұрын
i have a problem that when the bullet hits my player, the healthbar doesnt lower and the bullet doesnt also get destroyed after it hits me, i wonder that the bullet even touches me?
@chenpead
@chenpead Жыл бұрын
nvm i solved it with the help of chatgpt
@tankycatcool63
@tankycatcool63 Жыл бұрын
the little bullet doesnt go towards my player
@Nikelover.warspear
@Nikelover.warspear Ай бұрын
float distance = Vector2.Distance(transform.position, enemy.transform.position); It doesn't work, it show a mistake in Console...
@troutki
@troutki Жыл бұрын
Hi there, when my player dies the camera also goes away, how do I make the cam follow my player and not get deleted with the player?
@troutki
@troutki Жыл бұрын
Nevermind I fixed it
@chenpead
@chenpead Жыл бұрын
@@troutki how? i have the same problem
@zacharyhisaoka9194
@zacharyhisaoka9194 2 жыл бұрын
Great tutorial! Though I have a question wether its possible to tag all entitys with the same tag and have them shoot eachother without the bullet going for its parent. Basicly, exluding its parent from finding all objects of the same tag. Or a Minecraft skeleton shooting other Minecraft skeletons. Thanks!
@MX1732
@MX1732 Жыл бұрын
Does this work for top down?
@morebblakeyyy
@morebblakeyyy Жыл бұрын
Should do!
@jakubkonior2923
@jakubkonior2923 Жыл бұрын
Any idea why my enemy shoots at the player's feet instead of sprite's center?
@morebblakeyyy
@morebblakeyyy Жыл бұрын
Most likely the pivot point of your sprite is at its feet
@jakubkonior2923
@jakubkonior2923 Жыл бұрын
@@morebblakeyyy Thanks! That was the issue :)
@mmusiphoko5551
@mmusiphoko5551 Жыл бұрын
hi I have a problem , my enemy's projectile doesn't damage the player
@chenpead
@chenpead Жыл бұрын
u find a solution? i have the same problem
@mmusiphoko5551
@mmusiphoko5551 Жыл бұрын
My enemy projectile can damage the player but the projectile goes through the player it doesn't land on the player
@hoaxOT
@hoaxOT 7 ай бұрын
You're so quick i can't keep up imo. If your teaching beginners I would reccomend going a bit slower. I found it difficult to keep up and fully understand what you was doing
@polskigamer2643
@polskigamer2643 Жыл бұрын
you have misspelled the OnTriggerEnter2D. it is supposed to be onTriggerEnter2D
@morebblakeyyy
@morebblakeyyy Жыл бұрын
That’s false, it’s OnTriggerEnter2D.
@polskigamer2643
@polskigamer2643 Жыл бұрын
@@morebblakeyyy I have the problem with the bullet, when it collides with the player it doesnt destroy, it flies by the player
@dontmindmelol6780
@dontmindmelol6780 Жыл бұрын
Can i use the script for my player so it can aim without touch controls?
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
Should work...
@Florian69533
@Florian69533 8 ай бұрын
6:02
@xus9380
@xus9380 2 жыл бұрын
hi i have problem with the collision can u help me
@davidnagy2001
@davidnagy2001 2 жыл бұрын
You mean the bullet not destroying itself after colliding with the player? If so, put a BoxCollider2D on your bullet prefab and that should solve the prob.
@LcyYoutube
@LcyYoutube 2 жыл бұрын
Have you figured it out?
@lettuce_justice9263
@lettuce_justice9263 2 жыл бұрын
@@LcyKZbin I'm also curious now
@LcyYoutube
@LcyYoutube 2 жыл бұрын
@@lettuce_justice9263 Are you struggling? Maybe I can help
@lettuce_justice9263
@lettuce_justice9263 2 жыл бұрын
@@LcyKZbin Thanks for the offer, luckily I managed to fix it 5 mins later, had a missing piece, thanks anyway!
@neilaszemgulys6754
@neilaszemgulys6754 Жыл бұрын
Bullets dont vanish after 10 seconds. How to fix that?
@salaan0675
@salaan0675 Жыл бұрын
pretty sure its destroy(bullet,10) the first thing in brackets is the object the second thing is the ammount of time before its destroyed
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
U use the destroy function, example: Destroy(bulletGameObject, 10); This code has to be implemented in the bullet script
@neilaszemgulys6754
@neilaszemgulys6754 Жыл бұрын
@@UnsupervisedIdiotOfficial thanks
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
@@neilaszemgulys6754 no worries
@dieuthuydao8110
@dieuthuydao8110 Жыл бұрын
nhung em lam mai khong duoc
@SvoPacanaAigul
@SvoPacanaAigul Жыл бұрын
спасибо вам огромное (из России)
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
Ха-ха, Я тоже 句‿句
@morebblakeyyy
@morebblakeyyy Жыл бұрын
Пожалуйста :)
@MAS9Nine
@MAS9Nine 2 жыл бұрын
I get this error NullReferenceException: Object reference not set to an instance of an object EnemyBullet.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/EnemyBullet.cs:35)
@T0D4S
@T0D4S Жыл бұрын
Have you fix that? I’m struggling to resolve it
@Eastyoffutt
@Eastyoffutt Жыл бұрын
Have you fixed?
@MAS9Nine
@MAS9Nine Жыл бұрын
@@T0D4S yes
@MAS9Nine
@MAS9Nine Жыл бұрын
@@Eastyoffutt yes
@7sen651
@7sen651 Жыл бұрын
​@@MAS9Nine how
@Milco7
@Milco7 Жыл бұрын
grx
@bastianalvaro4500
@bastianalvaro4500 2 жыл бұрын
the bullet going another way from the player
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
Then set the force to the opposite number, example: if force is 10, set it to -10.
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
Hope this helps
@MAS9Nine
@MAS9Nine 2 жыл бұрын
Does it work for 3d?
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
No, it'll not work....
@MAS9Nine
@MAS9Nine Жыл бұрын
@@UnsupervisedIdiotOfficial bro. I’ve already tried that out. It was 5 months ago
@UnsupervisedIdiotOfficial
@UnsupervisedIdiotOfficial Жыл бұрын
I was just trying to help bro...
@elisabatista909
@elisabatista909 Жыл бұрын
What the name of the game?
@curiouskid1547
@curiouskid1547 7 ай бұрын
He is making a game silly
CHANGE PIVOT POINT OF SPRITE - Simple Unity Tip #1
0:26
MoreBBlakeyyy
Рет қаралды 25 М.
How to make a Video Game - #1 Player Movement
5:02
Evevemue
Рет қаралды 53
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
Хаги Ваги говорит разными голосами
0:22
Фани Хани
Рет қаралды 2,2 МЛН
Unity 2D Aim and Shoot at mouse position Tutorial
14:39
MoreBBlakeyyy
Рет қаралды 86 М.
Creating SMART enemies from scratch! | Devlog
5:40
Challacade
Рет қаралды 372 М.
2D Shooting in Unity (Tutorial)
21:12
Brackeys
Рет қаралды 1,3 МЛН
The Trick I Used to Make Combat Fun! | Devlog
8:12
Game Endeavor
Рет қаралды 1,7 МЛН
How to create an enemy SHOOTs at Player in Unity - enemy AI unity (Unity Tutorial)
10:24
FireRaccoon Games - indie games on mobiles
Рет қаралды 1,2 М.
2D PATHFINDING - Enemy AI in Unity
23:13
Brackeys
Рет қаралды 827 М.
Unity: 2D Shooting
4:17
Root Games
Рет қаралды 55 М.
SHOOTING/FOLLOW/RETREAT ENEMY AI WITH UNITY AND C# - EASY TUTORIAL
12:55