2D Shooting | Unity Tutorial (Two Types of Projectiles!)

preview_player
Показать описание

By the end of this 2D Unity tutorial we'll have our little character shooting and damaging enemies with our ranged combat system.

I'll show you how to aim your gun towards the mouse cursor (using the new Input System,) how to rotate the gun after a certain degrees threshold, and how to rotate your bullets when they are spawned in (as well as how to rotate them towards your velocity direction!)

To make this more fun, I'll show you an easy way to setup TWO kinds of projectiles that you can shoot.

I cover a lot here, so we're going to go through this 2D shooting tutorial fast!

Link to Download the FREE 2D Asset Pack seen in this tutorial:
---
---
Credits-----------------------------------------------------

Contents of This Video: ------------------------------------------

00:00 - Intro + Scene Explanation
00:42 - Rotating Gun Towards Mouse
03:58 - Flipping the Gun When You Aim Backwards
06:53 - Instantiating Bullets that Face the Shot Direction
10:27 - Get Bullets to Move in Shot Direction
12:21 - Handling Bullet Destruction
14:53 - Adding a Second Bullet Type to BulletBehavior
19:15 - Rotate Bullets' Facing Direction Based on Velocity
19:51 - Applying Damage to ANY Damageable Object

Who We Are-------------------------------------

If you're new to our channel, we're Brandon & Nikki from Sasquatch B Studios. We sold our house to start our game studio, and work full time on building our business and making our game, Veil of Maia.

Wishlist our Games:

Don't forget to Subscribe for NEW game dev videos every Monday & Thursday!

Follow us on Twitter for regular updates!

#unitytutorial #unity2d #unity3d
Рекомендации по теме
Комментарии
Автор

AMAZING !!!! You saved me for my Second Semester project love you

Ramesss
Автор

All of your videos are super helpful and very concise. Thank you

aazhisekar
Автор

I love these!
Would want to see you cover the system part, like game saving, data structure, handling multiple scenes etc.

meowl
Автор

Have you thought about doing a tutorial on the weapon system? Switching between weapons, maybe adding UI icons, etc.

capilover
Автор

A much simpler solution for handling collisions is to just use the collision matrix in the physics settings. That negates the need for any code.

midniteoilsoftware
Автор

2 time-saving tips: edit the script template so it doesn’t include all the boiler plate code you always remove anyway and there is a setting under preferences to create objects at origin so you don’t need to reset the transform every time you create a new GameObject.

midniteoilsoftware
Автор

A cool follow-up video would be how to use ScriptableObjects for bullet types.

midniteoilsoftware
Автор

There is one thing that I need help with. When I rotate my gun, it has a weird pivot to it and it doesn't stay in its assigned spot. Please help!

grassbash
Автор

I would argue that as you are setting the transform right to the velocity it doesn't need to be done inside a FixedUpdate.

CyberAngel
Автор

Please update the lesson for perspective camera! It seems to mess up your code

capilover
Автор

Hi there! Great tutorial as always. I've implemented this after doing the Hollowknight style camera tutorial which took a bit of figuring out as it effected the rotation of the gun (if anyone wants help just ask). The multiple cameras caused problems.

I am trying to modify this to suit my game. I have an ability system with upgrades and have tried to add a multishot upgrade, but its a bit buggy at the moment, it shoots three bullets at once in an arc but the extra two just shoot sideways :( I used Quaternion.Euler in the Instanciation of the bullet to be able to change its y axis rotation but that hasn't worked.

I'm also struggling with trying to flip the character when rotating the gun past 90/-90 degrees like the gun. The player movement and jumping is turned off and the attack ability is turned on as well as the gun when holding down the attack button. The player can flip when aiming past 90/-90 degrees like the gun however, when exiting the attack (Releasing attack button), if the player is facing left it messes up the flip function of the player so that he is facing the wrong way when moving. I'm sure ill figure it out, but if anyone has a good solution for flipping the character I'd appreciate the help!

nickrhyswarren
Автор

my bullet is being destroyed when it spanws, what can i do?

Teles
Автор

when I rotate, the gun rotates in the wrong direction. Please help

suzyeon
Автор

At 5:45, you could have just used instead of rotation. Correct me if I am wrong.

In the end, you use interface and grab a reference to that instead of grabbing enemy script. The reason you say is because there are other objects that get destroyed by bullet. But, you wouldn't add enemy script on other objects. Right ?. So only enemy gets to have enemy script and you don't need an interface there.

Really loved your video <3

y_go
Автор

A more concise syntax is if var damageable)) …

midniteoilsoftware