Hi everyone!

My three part FPS (first person shooter) tutorial is now officially in the Godot documentation!

This is the first tutorial I've done in awhile, so it's likely a little rough around the edges. Let me know if you have any suggestions on things I should change/add/remove!

You can also make a issue in the Godot documentation repository with your suggestions if you want, be sure to tag me at @TwistedTwigleg on Github if you want me to see it.

(I also plan on making a video tutorial too. Any suggestions/advice for making videos would be greatly appreciated!)

Wow, I started to read, a great one sir ! The first 3D tutorial on these forums - Hats off and many thanks !

Look children, a hero without a cloak! Thanks!

Great tutorial :)

I tried the complete version and there is an error, it can't preload ressource : var simple_audio_player = preload("res://SimpleAudioPlayer.tscn")

@TwistedTwigleg said:

(I also plan on making a video tutorial too. Any suggestions/advice for making videos would be greatly appreciated!)

About suggestions, i have only ones about code, but i'm not sure they apply as this is a tutorial.

  • Manage weapons as a table and a variable in player code instead of dealing with all weapons in code.
  • Each weapon would have it's own script and their own animations with common names (reload, fire, unequip).
  • Weapons raycast and other fire points would be included in each separate weapon prefab.
  • A variable "enabled" would let the script work or do something or nothing when weapon is disabled.

This makes things lot more easy to deal with and more expandable.

Pseudo code :


    if  current_Weapon != new_Weapon_choice
    changeCurrentWeapon(current_Weapon, new_Weapon ) ; 
    #
#        
    func changeCurrentWeapon(current_Weapon, new_Weapon ) : 
            #hide mesh and enabled = false for weapon script
    	Player_weapons.disable(current_Weapon); 
    	Player_weapons.enable(new_Weapon ); 
    	current_Weapon = Player_weapons.getIndexEnabledWeapon(); 

I prefer to have each weapon with it's own projectile prefab, each projectile prefab have it's own script instead of mixing them in the same code.

The main code is linear while it could be more modular and separate functions

func _physics_process(delta):

	readInputs(); 
	checkJump();
	checkRun(); 
	manageUI(); 
	checkChangeGun();

It's little differences, but i find getting things very modular saves me lot of time because it's more clear and lot more easy to expand or maintain. It's more work as you must manage more models independently like separate weapons and projectiles, separate scripts, but it's better for game projects getting complex.

I think it's perhaps better the way you coded it , linear , it's more easy for beginners to have something very linear and only one script to read and learn from.

When Godot will get C# fully supported, classes will be a huge benefit for object oriented coding.

Thanks MagicLord!

Manage weapons as a table and a variable in player code instead of dealing with all weapons in code.

I like your idea of breaking the weapons and their projectiles into their own scripts! I would like to say the reason I didn't do something like that was because I was wanting to make it easier to teach, but I'll be honest and admit the reason I didn't do it that way was because I couldn't think of a decent way to handle the animations :sweat_smile:.

Now that I've seen your pseudo code, I think I know how I could revise to code to use something similar. I'll have to play around with it, but it should be possible. Thanks for the pseudo code! It gives me some ideas on how to start!

If I do not change the weapons in this series of tutorials, then I'll definitely use a more modular system for the IK FPS (whenever I have time to start working on it... Too much stuff to work on at once! :cold_sweat: ). That said, I'll do my best to make a more modular system for this set of tutorials, as I totally agree with it being easier to deal with!

The main code is mixed and linear while it could be more modular and separate functions

Yeah, I probably should have broken them down into separate functions. Breaking it down will make it easier to explain too. I should probably revise the tutorial to use more modular functions.

But it's better as you coded it perhaps , more linear for learning when someone is starting.

I'm not sure if it's better or not. I suppose it is a matter of personal taste. That said, I like the idea of breaking everything down into more modular parts! I'll definitely see about breaking all of the code in _physics_process down into more modular parts at very least.

(Well, as long as the guys running the Github repository are okay with it :smile: )

With little modifications this could turn in some top down tps.

That would be cool!


Thanks for your suggestions! I'll do my best to incorporate them into the tutorial!

@TwistedTwigleg said: Thanks for your suggestions! I'll do my best to incorporate them into the tutorial!

I'm not forcing you :D This is the way i do it, keeping things separate and modular to make it easy to expand and debug.

The tutorial is fun

I have some idea that could be included in a new tutorial chapter grab and throw objects change weapons with mouse wheel.

I’m not forcing you I didn’t mean to imply you were, my apologizes if you felt like I was implying that! I was just agreeing with your suggestions. Honestly I kinda had a face palm moment when I realized how simple making it modular should be after reading your pseudo code. (I just realized what I thought was a huge problem was really a nothing problem :lol:)

Adding the ability to change weapons with the mouse wheel almost made it into part 3, but I decided against it last minute. I definitely plan on adding it in (with some other input related surprises :smile: ).

I’ll have to play around with adding the ability to grab and throw objects. I’ll put it on my list of things to look into!

Thanks!

9 days later

I tried SSR on your demo, it looks good.

@TwistedTwigleg said: Wow! That looks awesome!

It's Godot 3 and your scene looks awesome :) You can turn it to a game.

15 days later

How does one enable this SSR of which you speak, MagicLord? ;-)

You can enable it in the WorldEnviroment node(s) :smile:

You’ll also (likely) need to lower the roughness and/or increase the metalness parameter in the Spatial materials.


MagicLord, I hope you don’t mind that I used your screenshot in part 4 of the FPS tutorial. I can change it if you want, but I wanted to show how cool the scene looks and I didn’t have a screenshot handy at the time. Let me know if you want me to change it and I will :smile:

A good tutorial ?

Sorry to paraphrase MagidLord, but in my view, your teaching skills looks like a « must have » Numerous beginners and newcomers would want to see such tutorials quality. Yeah man, you’re a hero !

Peace upon you !

@TwistedTwigleg said: MagicLord, I hope you don’t mind that I used your screenshot in part 4 of the FPS tutorial. I can change it if you want, but I wanted to show how cool the scene looks and I didn’t have a screenshot handy at the time. Let me know if you want me to change it and I will :smile:

Do as you wish, it's your tutorial 3D art, my screenshot is only about adding SSR.

a month later

Hey guys!

I decided to remaster the entire FPS tutorial!

There was a few things I didn't like in the original FPS tutorial, and remastering it gave me a chance to fix a bunch of things. For example, now the FPS tutorial uses a more modular code setup from the start, as opposed to having part 4.

I also added three more parts! Now there's a bunch more stuff like turrets, the ability to grab and throw rigidbodies, health and ammo pickups, and a bunch more! (Technically I added 2 more parts, since part 4 was already there and I just dramatically changed it)

Let me know if anything needs fixing/changing/whatever. I'm happy to hear any feedback, good or bad :smile:

This is the best tutorial available in Godot, make it part of the official demos :) (I wish with funds they get , the Godot official team would do such tutorials)