Aiming in a 3D Top-Down Game in 3 Minutes - Unity Tutorial

  Рет қаралды 37,322

Bartha Szabolcs - GameDevJourney

Bartha Szabolcs - GameDevJourney

3 жыл бұрын

In this video, I will show you how to aim in an 3D top-down game with the mouse.
Copy the script from here:
github.com/BarthaSzabolcs/Tut...
Full project:
github.com/BarthaSzabolcs/Tut...
The dummy is from Mixamo, named "Mannequin":
www.mixamo.com/#/?page=1&type...
Idle animation is from Mixamo too, named "Standing idle", from the Pro Magic Pack:
www.mixamo.com/#/?page=1&quer...
Turret:
I made that piece of art my self.
It's not much, but you can use it, if you want to.
Music used:
chill. by sakura Hz / sakurahertz Creative Commons - Attribution 3.0 Unported - CC BY 3.0 creativecommons.org/licenses/b... Music promoted by Audio Library • Chill - sakura Hz (No ...
Cat footage:
commons.wikimedia.org/wiki/Fi...
====================================
These things are just for search optimization.
Will they work? I don't know, but I have to try! :D
#unitytutorial​ #unity3d​ #unity2d​ #topdown #isometric #aiming #gamedev #learnunity
Topdown, Isometric, Aiming, 2.5D, Unity3D, Unity2D, Tutorial, gamedev

Пікірлер: 83
@dadombom
@dadombom 4 ай бұрын
spent a while using other screen to world point methods, this cleaned up so many of the issues I was having! Thanks a ton!
@GamingAlgen
@GamingAlgen Жыл бұрын
This is so clear and perfect! Thanks!
@noworldorder
@noworldorder Жыл бұрын
This was incredibly helpful! Thank you so much for sharing friend.
@clockknight13
@clockknight13 2 жыл бұрын
Thanks so much! This is a very simple and elegant solution, helped me a lot in learning how to program :)
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Thank you, always glad to hear it helped. :d Best of luck with programming, it can be hard and there is a lot to learn, but it's worthwhile. :)
@Lazzarus7
@Lazzarus7 Жыл бұрын
Very inspiring, thank you for sharing and explaining
@TheVicRulz
@TheVicRulz Жыл бұрын
Thanks, i was stacked in a step!
@tiny_tin
@tiny_tin 4 ай бұрын
Wow, thanks! This worked for me very well
@deanwilsonmusic
@deanwilsonmusic 2 жыл бұрын
This works beautifully, thank you!
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Glad it helped. :)
@Ma_cieK
@Ma_cieK 2 жыл бұрын
beautiful and so simple!🙏
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Thank you! Really glad you liked it. :)
@unitygamedev2326
@unitygamedev2326 2 жыл бұрын
thank you so much bro , and happy new year
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
You are welcome. Happy new year. :)
@dmitriybelousov7246
@dmitriybelousov7246 6 күн бұрын
My best regards ! That is great and useful work !
@TheKr0ckeR
@TheKr0ckeR Жыл бұрын
Great guide. Thank you. How would we solve the problem of not having any collider? It just stucks there. I have some enviroments which is not a ground, and even an empty area, rotation is just stuck. Isnt there any way to look it with MouseWorldPos?
@GabiMartin97
@GabiMartin97 Жыл бұрын
Works like a charm
@hawkgamedev
@hawkgamedev 2 жыл бұрын
You are a genius thanks!
@PedroGuijarro_
@PedroGuijarro_ 2 жыл бұрын
Insane, works great!
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Thanks! :)
@rijkmulder276
@rijkmulder276 Жыл бұрын
how do you fix the problem of when aiming at the ground that the bullets arent going straight though the mouse but at a slight offset because youre shooting at a constant height?
Жыл бұрын
I love you man, you are my superman, thank you so much!
@IndieScapeGames
@IndieScapeGames 3 жыл бұрын
Nice tutorial!
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 3 жыл бұрын
Thank you! :d
@user-vo6om1hn3c
@user-vo6om1hn3c Жыл бұрын
Thanks! This is what i need :)
@DrDexaLoL
@DrDexaLoL 2 жыл бұрын
helped a lot, thanks bro :)
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
You are welcome, bro. :p
@reap8624
@reap8624 Жыл бұрын
it doesnt work whenever i try to use it it gives me an NullReferenceException error for the Getmouseposition() method
@Usual_User
@Usual_User 2 жыл бұрын
Thank you, this help me alot!
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Glad to hear that! :)
@criptas1985
@criptas1985 2 ай бұрын
TNX SO MUCH!!! U r my hero dude :D
@brehiner25
@brehiner25 2 жыл бұрын
I love this video but I wonder if you have this script for the unity touch system?
@BlueAndy_
@BlueAndy_ Жыл бұрын
Thanks a lot, very kind of you
@hidden2world894
@hidden2world894 8 ай бұрын
where did u get the turret? or did u make it?
@piruzRo
@piruzRo 5 ай бұрын
it works great but the moving controls are inverted do you knowk how to fix that ?
@darthvaderisawesome2573
@darthvaderisawesome2573 Жыл бұрын
THANK YOU VERY MUCH SIR !
@8BitTie
@8BitTie 2 жыл бұрын
Thank you so much I am new to coding and I hate copying scripts because I don't know what dose what. But in this case I actually don't feel bad about copying because now I know what each part of the script dose thank you I will subscribe can't wait to learn more about coding
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Am glad you could follow. :D I would say you should always try to understand the script that you copy, but don't feel bad just because you don't know exactly what is what. Also try experimenting with scripts that you copy, changing it a bit then testing out what did it changed. I found this to be a good way to test my understanding. Thanks for the sub. :)
@64mxg
@64mxg 10 ай бұрын
GRACIAS!!! justo lo que quiera comprender, como ahcerlo de una mejor manera :D
@halivudestevez2
@halivudestevez2 Жыл бұрын
for newbies: the return type is a "Tuple". Easy to use, but can be unusual to see it.
@halivudestevez2
@halivudestevez2 Жыл бұрын
Tuple: you can return multiple items at once without defining a new structure for it.
@yeahzerek
@yeahzerek 2 жыл бұрын
I might be slow but, how do you add that laser and circle thing on the ground? Also how to you make the shooting?
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
You are not being slow, I did not explained that part in the tutorial. :D I only meant to use it for the looks, but you can use it of course. If you want to copy the laser, download the project (github.com/BarthaSzabolcs/Tutorial-IsometricAiming), then check out the scene Example_Turret, in the hierarchy look for the GameObject; Turret > Head > Laser. The Laser object has a LineRenderer script, this is what draws the line. This is the first part. You also have to update the line every frame, so it won't go through the obstacles. You can find the logic in the script: Assets\Scripts\WithGizmos\IsometricAimingWithGizmos.cs, look for the function RefreshLaser() at line 162. The "circle thing" is a Gizmo, and can only be seen in the editor and if it is enabled, so this might not be what you want. You find it in the same script in the function OnDrawGizmos() at line 68. For the Shooting, same script, look for function Shoot() at line 153. This will spawn a projectile at the end of the barrel, and set it to face where you are aiming. The rest of the logic is in the Assets\Scripts\ExtraStuff\Projectile.cs In the Start() function it will set its velocity to go forward with speed. This works because Start() will be called after the projectile is set to face where you aim. Also you can find the logic to destroy the projectile on collision. Of course you will have to create a Projectile prefab that can be spawned. You can find the prefabs at Assets/Prefabs. If you get lost with the setup, check the Turret GameObject in the Example_Turret scene. I think that's all. Good luck! :D
@2800Print
@2800Print Жыл бұрын
Someway of doing this with bp ?
@allanramos6855
@allanramos6855 2 жыл бұрын
Nice code and tutorial
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Thank you! :)
@tylerguitar75
@tylerguitar75 2 жыл бұрын
What if your player is standing on sloped terrain? Would you make him shoot at a slope equal to the terrain?
@maximeumbra7235
@maximeumbra7235 Жыл бұрын
You've got two easy options on how to handle that, you first find that target position using this method then Raycast from world up down to it and set it to your desired height. If you want to get really fancy you then Raycast from a character source (say from a gun or the eyes) towards that new point and if you hit something before you reach that distance you could take that point and add some height to it or do raymarching to find the closest edge to aim as close as you can towards that desired target.
@Xeratas
@Xeratas Жыл бұрын
wouldn't you have to considder the camera angle? otherwise depending on the camera angle you will not always aim exact - please correct me if iam wrong here
@fercon9892
@fercon9892 5 ай бұрын
you are correct, this only works if the camera literally never moves, which is frustrating.
@EvertuGameTools
@EvertuGameTools 2 жыл бұрын
friend, could you tell me the name of this kind of method "GetMousePosition"😮
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Sorry, I don't understand the question. What do you mean?
@lazyonii-chan3885
@lazyonii-chan3885 29 күн бұрын
Is this possible on mobile? I want to make a top view game on mobile.
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 28 күн бұрын
You probably want twin-stick controls instead, where you move with the left stick amd control the direction of your player by the right analog stick. The method in the video would only work if the player continuously touches the screen, which would be distracting for a fast paced shooter.
@lazyonii-chan3885
@lazyonii-chan3885 28 күн бұрын
@@barthaszabolcs-gamedevjour1098 already did this one, i did it using movement joystick on the left and attack button on right. Thank you!
@diegooriani
@diegooriani 2 жыл бұрын
Quality.
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Thanks. :)
@vaepuer2290
@vaepuer2290 2 жыл бұрын
Doesnt work for me, but i'm slowly understanding this more
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Sad to hear it did work. Try to watch the tutorial again and spot any difference in your project and mine. You can also download the project, may be you can adapt the working code from there easier.
@vaepuer2290
@vaepuer2290 2 жыл бұрын
@@barthaszabolcs-gamedevjour1098 yea i tried adapting the full project to understand more, changed the camera to a dkfferent angle and yours worked flawlessly, however mine witht the exact same didnt. Probably just something i gotta put up on the forums
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
It's hard to guess, but I would start with the raycasting, may be your ground has no collider or the layermask is not set correctly.
@markfeeer2149
@markfeeer2149 2 жыл бұрын
Ne comment :D
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
Is this supposed to be a "nice comment"? :D
@markfeeer2149
@markfeeer2149 2 жыл бұрын
@@barthaszabolcs-gamedevjour1098 it does not matter to the algorithem
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 2 жыл бұрын
That's true. Thanks for your support! :)
@CyberAngel67
@CyberAngel67 3 жыл бұрын
this is not 2.5D, 2.5D was a term used for 2D graphics that mimic 3D. All I see here is 3D in a 3D world!
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 3 жыл бұрын
I got your point, but 2.5D often refers to a 3D game, with 2D gameplay. I did not want to call it top down aiming, cause you can achieve this easier in a traditional 2D top down game and there are a bunch of videos about it already. I think it's clear from the thumbnail what I mean by 2.5D. It's not necessarily correct, but I don't think it's misleading. What would you title it? :d
@CyberAngel67
@CyberAngel67 3 жыл бұрын
@@barthaszabolcs-gamedevjour1098 Other way around mate, 2.5D is 2D graphics mimicking a 3D world, always has been
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 3 жыл бұрын
​@@CyberAngel67 That does not change the fact, that a lot of people use it this way. Anyway, I changed it to 3D Top-Down, so it's more technically correct.
@CyberAngel67
@CyberAngel67 3 жыл бұрын
@@barthaszabolcs-gamedevjour1098 Name one? I have worked in the industry for 35+ years, 2.5D was a term we used to make 2D look 3D, and that is the origin of it. How do you make 3D look 3D if it is already 3D?
@glendunlop
@glendunlop 3 жыл бұрын
@@barthaszabolcs-gamedevjour1098 Whatever gets you through the day!
@71Arlekino
@71Arlekino 4 ай бұрын
Instead of transform.forward = direction * Time.deltaTime; it is better to write like this, for smooth rotation: Quaternion direction = Quaternion.LookRotation(movement); transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); Also sorry, but the accent is making my ears droop.
@devangganbote4334
@devangganbote4334 Ай бұрын
Nice Thanks!
@ttk519
@ttk519 Жыл бұрын
very nice, liked and subscrived, got discord?
@sammieisnotcool
@sammieisnotcool 3 жыл бұрын
Na már ezt is tudom. :)
@barthaszabolcs-gamedevjour1098
@barthaszabolcs-gamedevjour1098 3 жыл бұрын
Szívesen. :p
Переходишь с Unity на Godot? Посмотри это видео!
25:19
Тот Самый Келин
Рет қаралды 101 М.
How I made an Excellent Platformer
8:25
GoldenEvolution
Рет қаралды 251 М.
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 51 МЛН
100❤️ #shorts #construction #mizumayuuki
00:18
MY💝No War🤝
Рет қаралды 20 МЛН
Making a TOP-DOWN SHOOTER in 10 minutes VS 1 hour VS 1 day!
8:34
Blackthornprod
Рет қаралды 141 М.
The Trick I Used to Make Combat Fun! | Devlog
8:12
Game Endeavor
Рет қаралды 1,6 МЛН
PERFECT Weapon Aiming! (IK, Unity Tutorial Third Person Shooter)
13:36
How to get Mouse Position in 3D and 2D! (Unity Tutorial)
10:20
Code Monkey
Рет қаралды 135 М.
5 Minute Top Down Shooter Unity Tutorial
5:01
BMo
Рет қаралды 66 М.
Can You Really Make A 2D Game In Unreal?
6:09
Thomas Brush
Рет қаралды 78 М.
Tips And Tricks To Enhancing Your 2.5D World - Unity
6:17
ThatOneUnityDev
Рет қаралды 21 М.
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 51 МЛН