Hitscan Guns, Weapon Switching and Crosshairs - 3D Godot 4 FPS Tutorial
HTML-код
- Опубликовано: 21 окт 2024
- In this Godot 4.1 tutorial we work on creating a hitscan weapon for our zombie FPS game. The covered topics include shooting animations and mechanics, crosshairs, hitmarkers, bullet traces, hit particles, weapon switching, a simple weapon manager, and improved projectile guns. These mechanics can be used for many types of games, including FPS, horror, survival, RPG, etc.
Support the channel: / legiongames
The project is available on GitHub: github.com/Leg...
Wishlist Game: store.steampow...
Discord: / discord
Itch: legiongames.it...
Twitter: / legiongames1
Instagram: / legiongames1
Assets:
Steampunk Rifle by chiwei - skfb.ly/oEruW
Kenney Crosshair Pack - kenney.nl/asse...
Muzzle Flashes - opengameart.or...
Zombie model: www.mixamo.com/
Ground texture by 0melapics: www.freepik.co...
Kenney Graveyard Kit - www.kenney.nl/...
Steampunk Rifle by Jake Sharp - poly.pizza/m/1...
I just want to thank you for your intro tutorials. I followed some initially to get the idea of Godot's syntax in a project I felt a bit more aligned with after their documentation's. It helped me figure out some basic ideas and expand on them.
Later on, I moved most things into a more composition based approach - but for the total beginner, this stuff was great!
one of the greatest godot tutorial channel, please keep it up
Thank you friend!
Some suggestions for the future tutorials for this series: ladders; interactable objects(door, chest, lamps etc...); health bar, and player death; maybe a counter, that counts how many zombies have died.
Oh yeah ladders would be really cool! I want to do some objectives for the level in the future so I think interactable objects will definitely be on the roster.
Great tutorial so far. Just one thing, there's no need to use signals for the hit marker on the zombies. Since you're already checking for collision with an enemy group in your raycast, all you'd have to do is display the hit marker inside that condition.
Great video as usual! Would love to see more like it.
Quick suggestion to others following along -- the crosshair I find easier to do it like this: make the TextureRect a child of a Control node, make the control node expand to screen size, and set the TextureRect to be centered. This accomplishes the same thing without needing any code and it updates with the viewport as if it changes size (windowed/full screen)
NOTE: Any control nodes in your scene will BLOCK mouse activity by default, so go to any control nodes you have and under the "Mouse" setting, change the "Filter" option to "Ignore". Do this with ALL control nodes you have and you'll be able to move as usual.
Thank you. This should be pinned.
Quick question if you don't mind:
I've followed your advice, but whenever I change the size of the viewport, the crosshair still lingers in its place. Any ideas why? thanks
@@jjl2844 If you followed what I said, the only thing I can think of that would prevent it from working is where it is in the hierarchy of nodes.
Is the control node you made a child of something other than the base/camera node? If so I'd try bringing it to the highest level (making it a child of the main node or camera node) and make sure to set it to expand again just in case. You should see it expand to the full viewport size in the editor.
Hope that helps!
Just a suggestion but work on how you edit the videos, making no pause between different speeches make this video pain to watch/listen. I try setting it at 0.75 and even 0.5 speed but it doesn’t help a lot.
Yeah i'll work on that, thank you!
In the UI Crosshair Segment, if you cannot move your mouse, go to the UI layer and look at the Inspector. Find "Mouse" and look for "Filter." Then change "Stop" to "Ignore." Your mouse should be working again now.
THANK YOU
thank you so muchhhh
thank you
Awesome tutorial! Thanks!
Thank you friend! :)
the tutorial is really good but i would prefer it if a lot of things are simplified, such as the bullet trail using particles, and killing the zombie internally within script without any world script, etc. and i would also like to see a multiplayer tutorial. This is really amazing, only good tutorial for gun shooting in godot 4, the other creators are not yet updated to use this engine in tutorials.
Great tutorial! One bad practice with these video though which I would encourage people against is putting all the UI on the world/map level. Instead move your crosshair and hitRect into your player instead, so that it is actually reusable and completely independent of the map-scene...
Completely agree, some bad decisions were made in this tutorial.
Awesome content.
Please make a tutorial on how to make terrains, mountains and uneven landscapes.
Thank you! :) I've been trying to figure out an easy way to do it in Godot 4 since a lot of the terrain plugins are not updated from Godot 3 just yet, but I'm definitely doing that in the near future!
Thank you! Very informing and good vidios. Better then most RUclipsrs!
I'm glad you're enjoying the videos, thank you very much! :)
Your tutorils are amazing, and clear, my only points would be to be a little slower (granted youtube allows to adjust speed), but men, I'd definitly buy a full fps course if you ever do one ! :D
Good tutorial. Thank
Solid tutorials recently! Would love to see this and the char controller in a multiplayer scene; after all who doesn't like blasting zombies with your mates. :)
Yeah I'd love to do a multiplayer tutorial eventually as well, I'm looking into it atm but we'll see how viable it is to refactor this game for multiplayer / making a new one from scratch.
Will you continue this FPS series? Maybe a melee attack? @@legiongames2400
Have you thought about making a melee combat tutorial? It would be great to have a solid melee guide that feels something like Risk of Rain 2's melee combat.
Great tutorial! Just had one question. Why do many godot tutorials on the weapon system(including yours) have the weapons already on the player node. Why not instantiate them when you need them. Is there a specific reason for this that I should learn about? Thank you for the great videos. Keep up the good work!
awesome work! keep it up!
Thank you! :)
this serie is FANTASTIC !!! Thanks a lot for doing it ! HOwever, it would be really cool imo if we had a kind o fhealth system for the player... XD, right now there is not many stakes or risks is there ? XD
good tutorial man, btw by any chances can you make a tutorial for aiming down sight in godot i was new to it especially godot 4 so it would help me alot if you do.
Just in case anyone had the same problem as me, if after you create the crosshair your mouse stops turning your character, what I did to fix it is inside of the crosshair ui element there is a section called "Mouse". Click on that and inside you should see a "Filter" option. Mine was set to "pass" but once i set it to "ignore" my mouse was working again.
Dude, your tutorial is great, but when I press play, the weapon always appears below the camera, I looked for something wrong in the codes and animations but everything was fine. Can you help me?
I'm not sure what's going on there, you double checked that when you preview the camera in the editor the weapon is visible?
@@legiongames2400 yes, but it is only under the camera
Thank you so much! I love your tutorial, can you make one about infinite map terrain generation, sound design(guns sound reload and animation, footstep and melee sound) and cover about realism? Like enemies with guns? Or footsteps? Or even inventory for a looter shooter(I don't think there is a single tutorial on youtube for it)? I am sorry if I ask too much. But I think if you can cover these topics in your video, I think it would be really awesome and a lot of people would find it helpful.
That is just food for thoughts though:
These are some really great ideas you can cover and as a beginner your video is really helpful and awesome! I know making these video are tough especially editing take times and writing script for the video is not very easy.
Thank you for watching and the ideas! I don't think I'm going to do infinite map generation for this one, but sound design and ranged enemies are definitely on the list. Item pickups eventually as well, but for a robust looter shooter system you may want to look into some RPG game tutorials because they have very the same type of inventory systems that looter shooters do.
These are awesome. Please also do a arkham style free flow combat system if possible❤❤
Thank you friend! :) That's way more difficult to do but hopefully I'll get around to it sometime!
wish this tutorial was slower
I'm new in the 3D game and i followed your tutorials and i loved it. But i wanted to ask you if I want to add score system and show damage of enemies where do i have to add. Can you give me slight hint it would be a great help!!!
Awesome!❤
🙌
thanks for these materials but I have a request if you could insert the next part of the system of life and death pleats
Thank you for watching! :) Yeah definitely need to include that haha :D
if I have multiple animations how do i make it so that the left hand stays locked with the weapon? i already know how to lock one hand. the problem is when i play an animation one hand is locked in good but the animation doesn’t coincide with the other hand. so it doesnt look good. im doing a third person game. and if i go into blender and parent the weapon to one hand, export it into the game it doesnt stay locked. it floats free so im back to square one
I want your game because your game amazing
Great tutorial. I think it will be nice to add gun recoil to hitscan weapon, I can think of adding some randomness on each shot, but the gun in csgo seems to have pattern for the gun recoil, so the players can learn from the pattern, still thinking of how to adding fix pattern gun recoil to the shooting
Yeah recoil is definitely necessary there because otherwise it just feels like a lil laser gun, vid was just very long already. Thank you for watching! :)
Really good video. I have a question: will there be weapon reload and pick up?
Definitely going to be weapon reload and pickup, will try to get around to it asap. Thank you for watching!
Cool
Thanks for these great tutorials! They've been really helping me get back into the groove of using Godot. I'm having a weird problem with my bullet trails though: No matter what I use for the "pos1" in both the "instance.init(barrel.global_position, aim_ray.get_collision_point())" or "instance.init(barrel.global_position, aim_ray_end.global_position)", whether it's the barrel of the gun or a different point on my character, the trails always start off spawned a bit above my player's head. I even tried changing it to use the aim_ray position as pos1 so it would start in the center of my camera but it still spawns above my head. The ending position (pos2) also seem off. Even when they stop because they hit something, they're usually floating a bit above whatever they're colliding with (like stopping because of a block, even though it doesn't look like they're colliding). Any ideas what could cause this?
Hey thank you very much for watching! I'd assume the problem is somewhere with the global positioning of the things around the level. The code relies on global positions of both the gun barrel and collision point and if you add the trail as the child of something that has any position transforms applied that would mess up how the trail appears. So double check that your map or whatever you're adding the trail to is positioned at 0, 0, 0 coordinates.
@@legiongames2400 Thank you for the reply! I'll have to double check everything when I get home, but I think I might have my character's starting position as something like 0, 2, 0 so that would probably be the cause!
@@legiongames2400 Just got home and double checked and yup, 0, 2, 0. Moved the character to 0, 0, 0 and shifted the test level's geometry down a bit instead and everything works perfectly now! Thank you so much for the help!
thanks man can you add 3rd person tutorials please i really like your videos
Thank you friend! What kind of 3d game were you looking to make?
@@legiongames2400 i am trying to make a third person survival game like last of us
i am sorry for the long wait just finished school please can u make tutorial on it please
do you not review your videos before posting? I feel like everything goes too fast and i don't have time to look at what you did before you've already hopped on to the next thing
I've been using Godot 4.1 and it launch me off the map as soon as I run. It was a quick noclip off the map without touching the keybinds
Haven't really ran into this problem before, what code are you using for movement?
@@legiongames2400It was CharacterBody3D code
great content! do you have a tutorial on third person shooters?
Thank you! Unfortunately not yet!
honestly could do without the "bullet trails" as they literally just look like debug lines to me but other than that fantastic work, subbed
CAn you add more enemies and some RPG elements like quests, inventory and stats
And a melee weapon?
i decided to download the project and see how it works and the zombs were invisible
I almost fell asleep watchng this
Can you say how make shotgun?
Well, after extensively searching on Internet, no one made a inteligent enemies in Godot... Yet... Enemies that dodge bullets, hide behind obstacles... Is it so hard to do?
Please can you do a tutorial for an enemy AI that shoots at the player when they have line of sight
Thank you for watching! :) I have a couple of other video ideas lined up at the moment but ranged enemies are next in this series.
How to add a hit animation. Well, a few random attacks?
Have multiple attack animations in the tree and choose which one you play depending on a generated random number maybe?
@@legiongames2400 No, it's better to just shoot at the enemy. And he will have a punch animation as if he is pushing away. HIT animation.
Export the project and upload it to itchio to test it!
When I move the gun for the animations it's position resets in the main scene cause it to glitch out, does anyone know how to help
Thank you!
Please can you crete playlist FPS Tutorial?
Will do! Thank you for watching! :)
please add sound to you game