I have been following your tutorials for some time. Thank you for everything
Wow, I didn't know there was a compiled version of the videos. I'm so glad I found it! TY :)
you are a life saver, this channel deserves more suscribers.
Thank you so much for your work, Know that you helped your example a lot because you gave a general picture of how to do it! Your channel deserves a lot more subscribers and views!
I love this because its not super beginner but does a very good job of showing what to do and why.
a lot of insight while watching, Thanks for the gold!
truly a giga chad, well done chaff
Thank you for share ❤
Thank you so much
For everyones sake, I think you should add this to the description of the video, or edit your pinned comment and add this:
Add a tag of which type your variables is, it really help soooo much when coding in godot. For example.
var Current_Weapon : Weapon_Resource = null
By adding : Weapon_Resource, godot will now show you auto completion everytime you refer to this variable. :)
Oh yeah how good is typing now. Back when I made this it was still done a lot less. 3.5 days barely anyone did. And now I would consider it mandatory, it gives you a lot of extra help.
Very good idea🤩🤩 this is a conglomeration of individual episodes or no???
AMAZING
Something I would like to see added to this video is for the weapon pick up section. In the video the script takes a selection of variables that you have to hardcode in for each spawnable item. I would recommend changing this to accept the resources directly, as it prevents potential user error. The change is as simple as replacing the @export variable declarations with @export weapon: Resource. Then you can access each variable with weapon.ammo or weapon.weapon_name. Hope this helps!
Thanks bro
Amazing video, a few thoughts:
- how could I go about starting or switching to unarmed?
- how I could implement picking other things up (swords) and using them
Same as anything. For un armed you can create a resource for it. Obviously, it can’t be dropped 😂. Swords and melee weapons would be the same however, you might need to customise the shoot function to support a third way of detecting a hit. I do my melee strike with a simple 1 meter ray cast. Which would not be sufficient for a game based on melee weapons like swords. I would look into using an area3d to detect the space in front of you. Or more advanced continuous ray cast along the weapon to detect a strike
Good vid
THANKS a very good and complete tutorial very well explained don't copy paste you learn how to do
"if it's working, it's working..even though the code is messed up" :P
would you be able to do a tutorial on Red Orchestra style freeaim deadzone (where the gun moves separate from your camera) ?
Not sure if you ever cover it in another video, but how would you go about adding a bullet hole decal system to replace the hit markers? I've seen other people use a ray cast as a child of the camera node, and from there they get the collision normal and rotate the decal accordingly. The ray you created in this system detects intersections using code so it's a bit different, but would bullet hole decals it still be possible?
The information from the second ray cast should be enough to do such a thing, it carries the exact same information. I create a very basic hit decal in this video. However I believe the way I do it may be a bit outdated. There is a decal node that I have not yet played around with that may be more useful for displaying a bullet hole.
* print with `print("Health is: ", health)` (instead of concatenating with +), then you dont have to do string(health)
28:24 Hi, I was typing your code when out of nowhere on line 29 the message 'Invalid get index '0' (on base 'Array)' appears, what should I do?
Hey, what do you have on line 29? An invalid get index normally means whatever you’re requesting is non existent. Jump in the discord if you want to post screenshots and we can get you up and running
Im so gonna watch this... just later
There’s individual episodes if you want to pick through them individually. I have a playlist on my channel
Excelent tutorial. Coukd you do the same but for 2d?. Thanks
Hey, thanks ☺️. I don’t really do too much 2d these days but miziziziz put out a tutorial recently ua-cam.com/video/UYQfVx1EIW8/v-deo.htmlsi=mVwYoZ8fhFeM8fRa
I get the error "Invalid index type "String for a base of type "Array"." for the Change_Weapon function:
func Change_Weapon(weapon_name: String):
Current_Weapon = Weapon_Inventory[weapon_name]
Hey, Check the declaration of the Weapon_Inventory, it should be declared as a Dictionary. Not an Array.
i really need help
at 40:20
the game keep crashing , says breakpoint at function ready, i don't know what is wrong, i did everything just like you but...
also i deleted everything from the hud script to signals and disconnected them and did everything again and still crashing
i have godot 4.2
Maybe try removing the break point? Look for a red dot on the side of your script then click it.
Hello Chaff! My hitscan and projectiles weapons are not shooting to the center of the screen, they go straight from weapon position. What am I doing wrong? Thanks
The first thing that comes to mind is the direction math that is done at the start of the projectile function. But if hitscan is doing that as well, I’m not too sure. First time I’ve heard that. Are you using a custom resolution for retro games?
I have a problem that the scene is restarted, but the value in the weapon, for example, the current ammo or reserve ammo are not returned
im done with camera and movement, but whenever i run it, it says not responding. anything i can do to fix this?
Haven’t seen that before, are you getting any feedback from the engine as to why
I don't expect you to reply, and I do apologise if the answer is in the video - but I'm just asking ahead because I won't be doing this anytime soon so I'm just asking incase you can answer.
Does the FPS system work with other camera/movement systems or is it somehow crucially tied to the one you made in this video?
In this tutorial I don’t touch the camera except to move it with the mouse. So if you wanted to have some other set up it will be fine.
I didn't see you show or answer this question, what are the layer and mask for the characterbody? I think that my bullet projectile is somehow colliding with my player, and I don't want that to happen.
For anyone interested I set the layer to player, and the mask to world and player and it worked.
Good point. I talk about the layer concerns for projectiles at 1:12:46. I provide very general advice on the problem, however, I do not say what layer the player is on. You're solutions below is how it is set up.
I am using godot 4.2 and no script templates showed up when I followed your instructions from the start. Any clue what I can do?
Hmmm, that’s not something I’ve had to deal with before. Is there an editor setting maybe?
does the gun recieve shadows or are you moving it out of the way when you walk too close to walls?
In this series i don’t implement any view model clipping solutions. The models should receive all lighting information including shadows.
i apologize i see you have a video on how to get camera to show but also receive light. gonna give that a watch here in a bit. this is a good set up.@@Chaff_Games
@s3nju279 I’m making an update as well. I think in godot 4 the subviewport does not show shadows.
I'm at the hitscan portion of the tutorial and am getting a weird issue (godot 4.2.1). Despite weapon range set to 2,000, I only get hit detection within like 3 meters. However, at ten meters away, I only get hit detection if I move my mouse over the target, but I only get one hit detection before I have to move my mouse again to get another. And If I WASD maneuver my reticle over the box, I dont get any more hits until I move my mouse. My code seems identical, but I'm prone to overlooking things. I'll continue with the tutorial and maybe you'll address it at some point or I figure it out. I'll update this comment.
That’s the first I’ve heard of that. Jump on the discord and we can try and figure it out
@@Chaff_Games I went on vacation and didn't get to reach out, but I just figured it out though!! I had both the camera height and player capsule height at the same height. This lead to it sometimes thinking was colliding with my own head. TLDR Make sure the camera is INSIDE the player collision shape like you had it or you get very weird ray casting behavior. Cant wait to continue with the tutorial now lol
great video and lesson thanks, but I have an interesting problem. I noticed that bullets (projectiles of a weapon firing projectiles) They repeat some of the character 's Input when they lie on the ground after a shot , like jumping and walking . I have no idea why at all.
Hey there, the reason for this is that the rigid body projectile needs to be set as top level. If you don’t do this then the projectile will follow the transform of the player.
@@Chaff_Games excuse me I'm a beginner for that , but where is top level the bullet in our separate scene, or are you talking about something else
@@Chaff_Games Damn, I missed it. Yes, everything worked fine, thank you very much
Hey im javing trouple importing your zip file to a new project of mine. I recently doscovered your project file template online and relized it is perfect for what i want. I download it and go into godot then i import the zip file as a new peoject all the files load on but the project doesnt load it says missing dependency of character controller. Plz help.
Are you trying to load on an android device? It’s the only place I’ve encountered that error. Which seemed to go away when I closed and re opened.
@@Chaff_Games yes I actually am making a mobile fps zombies on my phone using godot mobile and it worked when I loaded again 🤣 I can't believe I didn't just try again I'm dumb thanks for the feedback you earned a sub.
Guys if you add this line to the end of the pick up detection:
if body.pick_Up_Type == "Ammo" && weapon_Stack.find(body.weapon_Name,0) != -1:
body.queue_free()
then it will remove the clip, after the pick up and you won't pick up the clip, if you don't have the gun for it.
At around 39:24 I got a problem. When using the signal I get this error after launching the game: Invalid call. Nonexistent function 'set_text' in base 'Nil'. Any ideas?
xd, too
do you found solution?
upd: I found core of error. signal is works faster than @onready -> variable is null
upd2: I moved declaring variables in to the functions. its work correctly. but i dont think is good solution. reply me if you find better solution.
Hey, the easiest way to fix this is to make sure that your canvas layer is above the weapon manager. The scene is created top to bottom when the game starts so if it's above the weapon manager then it will exist when the signal is emited. You could always put a time delay on the first emission as well.
@@Chaff_Games I fixed it by declaring the variable in the CanvasLayer Script. Thanks though!
hey chaff! this is a really helpful tutorial, but I'm having one issue. for the hud code, I followed what you had coded closely but a issue has arisen. The Ammo label has a breakpoint. I do not know what it is, or why it isn't showing the ammo. If you need me to, I can post the code its self and maybe you can help fix the issue. I know being a dev and a youtube can be quite busy and I understand if you cannot reply to this comment immediately or at all. Anyways, hope you had a wonderful holiday.
@@Chaff_Games will do, is there a channel you want me to send it in? or would you want a direct message?
MOUSE SENSISITIVY
how would you add full body models for multiplayer?
You would need a few things. For the other players you would need an animated rig and a way to sync the animations across the server. I’ve never done that before.
@@Chaff_Games would full body be on another and how would you code the animation
Help, I followed everything in the tutorial but for some reason I always hit the player CharacterBody3D as the first and only collider. So the Hitscan and projectiles dont work...
Hey, Thanks for your patients. I tried to re create this issue but I was only able to hit the player collision if I move the collision shape in front of the player. Nevertheless, you can add the code New_Intersection.set_collision_mask(0b11111101) to exclude the player. Assuming the player is on the second layer. Add this right below where you create the physics ray query parametre. Thanks.
@@Chaff_Games I ran into this issue too with Godot 4.2. I don't know if this person is doing the same thing but I had switched to the Jolt Physics engine(going to be the default in the future). Something is different and causes the raycasts to hit the player even though my bullet point is clearly forward of the player's collision shape. Once I changed it back to the default physics, it worked fine. I'll do some more debugging and see if I can figure out what it is.
I think it's that Jolt raycasts are more accurate than the built-in physics engine. When the player looks down below level with the horizon, the bullet point gets rotated inside the player's collision shape. Jolt apparently detects collisions that begin within a collision shape and exit them as a collision, where the built-in engine does not. That's my current guess at least. I think the correct solution is to use a mask like you suggested.
@@tmilker I actually figured out what this is. Jolt 0.10 and under, you have to set new_intersection.hit_back_faces = false - they fixed this in the latest version of the engine in 0.11 so you should probably just update
@@swordofglassThanks, that certainly explains things! It appears Jolt version doesn't matter because I just checked and by default hit_back_faces is still set to true. (I was already using 0.11)
Hi There, what is the license for the code / tutorial etc? Just before I start! Thanks
And also wondering about the assets / project file. What the license is for that / if we can use it (credit). Thanks :)
If you download the file, I use kenney.nl assets, which are all CC0. The code is all MIT. So nothing in the project requires credit.
Wish someone did this for C# lol I have the worst time using C# in Godot, I just can't fucking figure out half the shit. I might have to stick with Unity or Unreal :| but I don't want to
Nothing wrong with gdscript. But i Guess it depends on what you’re making.
How do I find out how you made the initial world
@@Chaff_Games Cool. Could you provide the starting project that only has the initial world? I want to follow your tutorial step by step.
I did all the things for camera and keep getting errors for some reason even though I copied you. I have tried so many tutorials for camera mouse and can never get it for some reason.
@@Chaff_Games Dosent matter now cause I deleted it. It would just say things like it wasn't declared or something like that on certain lines
@@exploringbiblicalendtimes779 well if you need more help, jump in the discord and we can walk through it.
At 9:33 i get an error in line 23 and 30. I did exactly what you did
@@Chaff_Games
But i have MainCamera as a child node of CharacterBody3D:
0 - res://scripts/player_controls.gd:30 - at function: CameraLook
1 - res://scripts/player_controls.gd:23 - at function: _input
player_controls.gd:3 @ _ready(): Node not found: "$MainCamera" (relative to "/root/world/CharacterBody3D").
I'm actually having a similar problem with this lol. It's saying Node not found: "%MainCamera" (relative to the Character Body
@@Chaff_Games
Try taking out the %. Or just re initialise the camera node variable for your particular project. I used an old method or alternative method that can be confusing for new comers.
Yeah. Removing the % sign did it and I was able to troubleshoot it. I'm learning a ton and thank you so much@@Chaff_Games
im struggling getting it to boot after adding the weapon manager. I am getting a breakpoint error. I think I Have everything setup correctly. my animations are in a library so it would be p90/activate. Breakpoints are at line 20 so "Initialise(Start_Weapons)" and another at "Current_weapon = Weapon_list[Weapon_Stack[0]]"
I added p90 as a starting weapon but still am getting the breakpoint errors.
im an idiot. I didnt realise what Breakpoints where. I will try again now@@Chaff_Games
Pls help.
This is my weapon manager script
var current_weapon = null
var weapon_stack = [] # An array of weapons currently held by the Player
var weapon_indicator = 0
var next_weapon: String
var weapon_list = {}
@export var weapon_resources: Array[Weapon_Resource]
@export var start_weapons: Array[String]
func _ready():
!Initialize(start_weapons) # Enter the state machine
func Initialize(_start_weapons: Array):
# Creating a dictionary to refer to our weapons
for weapon in weapon_resources:
weapon_list[weapon.weapon_name] = weapon
for i in _start_weapons:
weapon_stack.push_back(i) # Add out start weapons
!current_weapon = weapon_list[weapon_stack[0]] # Set the first weapon in the stack to current
enter()
func enter():
# Call when first "entering" into a weapon
animation_player.queue(current_weapon.Active_Anim)
func exit():
# In order to change weapons first call exit
pass
Whenever I try to run the game I get the error
Invalid get index ‘blasterB’ (on base: ‘Dictionary’).
My errors are on the lines that start with ! 28:58
An invalid get index on a dictionary usually means that the variable you’re trying to get from the dictionary, isn’t there. So following the code, we know that there’s either a problem with the weapon lists creation, or there’s a mismatch of variables in either the weapon name or the starting weapons variables (which we are using to reference our dictionary). Check both of those and let me know how you go.
Changing the variable gives me a different error
Invalid get index ‘Active_Anim’ (on base: ‘Resource (Weapon_Resource)’)
Although deleting the line to queue the Active_Anim gets rid of the errors
Does that variable exist in the weapon resource? I named it Activate_Anim. Renaming is obviously fine but make sure they match otherwise this error will present itself.
Thank you so much!
I wrote active_Anim instead of activate_Anim
Definitely subbing ❤️❤️❤️
hitscan is no working
Works fine for me 😂. Jump on the discord if you need some help finding where you’ve went wrong.
why not use deg _to_rad ( )
Thanks for the feedback. Could you please tell me at which point in the video you’re asking about?
@@Chaff_GamesBit late to the party but they are probably referring to the rotation of the camera controls.
They way you've done it works fine, but by converting the degrees to radians you can use smaller numbers for neatness, it's how I've seen other people approach camera controls in other tutorials.
Yo ima keep debugging it on my own but might aswell ask. At 40:14 I get the same error but my "@onready var"s are correctly set or atleast dont have the New part added. I tried dragging the node location like you demonstrated and typed it out aswell but neither are working. It is stuck on the exact same line as yours was on 40:14. Do you have any ideas why this could be?
"
@onready var CurrentWeaponLabel = $VBoxContainer/HBoxContainer/CurrentWeapon
@onready var CurrentAmmoLabel = $VBoxContainer/HBoxContainer2/Ammo
@onready var CurrentWeaponStack = $VBoxContainer/HBoxContainer3/WeaponStack
"
func _input(event: InputEvent) -> void:
if Input.is_action_pressed("ui_cancel") :
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if event is InputEventMouseMotion:
rotation.y -= event.relative.x #horizontal
rotation.x -= event.relative.y #vertical "Camera".rotation.x -= event.relative.y
if event is InputEventMouseMotion:
rotation.y -= deg_to_rad(event.relative.x * sensitivity)
main_camera.rotation.x -= deg_to_rad(event.relative.y * sensitivity)
#script full
extends CharacterBody3D
@onready var main_camera: Camera3D = get_node("main_camera")
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
var camera_rotation = Vector2(0,0)
var sensitivity = 0.1
func _ready() -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event: InputEvent) -> void:
if Input.is_action_pressed("ui_cancel"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if event is InputEventMouseMotion:
rotation.y -= deg_to_rad(event.relative.x * sensitivity)
main_camera.rotation.x -= deg_to_rad(event.relative.y * sensitivity)
main_camera.rotation.x = clamp(main_camera.rotation.x, -1.2, 1.2) #main_camera.rotation.x = clamp(main_camera.rotation.x, deg_to_rad(-90),deg_to_rad(90)
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
HELP!! PLEASE 24:46
I typed and did exactly what it said but it gives me an error
extends Node3D
@onready var Animation_Player = get_node("FPS_Rig/AnimationPlayer")
var Current_Weapon = null
var Weapon_Stack = []
var Weapon_Indicator = 0
var Next_Weapon: String
var Weapon_List = {}
@export var _weapon_resources: Array[Weapon_Resource]
I just want to confirm you’re using godot 4? Because I’m pretty sure this error was present in other versions? Other than that double check the weapon resource and make sure name is the same and that it is a resource. And if all that is correct then, it should work, even the error message agrees with us (we are exporting a resource).
I just switched to 4.1 from 4.0 and it seemed to fix the problem. Thank you!@@Chaff_Games
hmmm perhaps this bug existed in Godot 4? I know it's a new feature but i thought 4 and up. perhaps i need to update the description. I'm glad it's working for you now.
porque cuando roto la camara me da error en transform.basis = Basis()
MainCamera.transform.basis = Basis()
This is a compilation of all my tutorials so far combined into one. So you don't have to go hunt down the other videos.
Ok I understand thank you👍
Can you add chapters to this video if we want to scroll to a specific one?
@@notimportant3033 yes I should have done that sorry. Will do as soon as I get home.
@@Chaff_Games It’s okay man, thanks
👍