For those using this tutorial with later versions of Godot4... OpenSimplexNoise is outdated, you can use FastNoiseLite instead, which has simplex and simplex smooth as options.
Quick note: In games like 2D marios (at least the older one) the way they handle jumping is much more straightforward than you'd think. The jump speed is a constant and the only thing that changes is gravity. In SMB1: the jump speed is 4 (or 5 if you're sprinting), and gravity just changes depending on whether you're holding A or if you've already started falling
too fast and too hard to understand :( Is there a way to select a resource to use in script instead of in the inspector? I have like 200 enemy stats resources but I will only be fighting 1 enemy at a time, so I think it would make more sense to access 1 resource in the script at a time rather than dumping 200 into an array.... does that make sense? I just want to access 1 resource at a time in script, how would I do that?
I tried to use this for my game. The problem I ran into was that when a jump is intiated and the player collides with a wall before jump_height is reached, the player slides up the wall, till the jump_height, before sliding back down. Is there a way to stop the slide upward, when colliding with the wall. Im new to godot and this is my first game I am developing
Anyone know why time to peak somehow changes the jumpheight? is this supposed to happen??? I just want the jump height parameter to be the single thing determining the height, and jump time to peak only changing the time and not actual jump height
@@Pefeper ok good so it was something with my code then. I haven't tried using your entire player template. I just ended up not using this method and going back to the guessing game. I do like where my player physics is going tho rn.
I wish I knew about those sooner, I've spent hours slamming my head against the wall because godot moves around files in the PCK on export. With resources this is a non issue...
I typed in ResourceSaver.save("user.//savefile/save_file.tres") It gave me an error: Invalid argument for "save()" function: argument 1 should be "Resource" but is "String".
You mention resources are "easy to load". Can you explain how? As far as I know there is no function to LoadAllResourcesOfType() at runtime f.e. which was one of the main reasons I stopped trying to learn Godot a while back.
Small tip : in the timed explosive resource, you manually preload a scene for the explosion. Instead you can also make this an export variable of PackedScene. This has 2 benefits, moving scene file doesn't break the loading and you can now have different explosions!
Thank you for the video! Two ideas to improve the code: 1) Make your jump_height value negative (e.g. -100) and remove the -1 multiplications from your calculations. 2) Rename jump_time_to_peak to jump_seconds_to_peak and jump_time_to_descent to jump_seconds_to_descent. Why? 1) Don't add the circumstance that in Godot Y -1 is UP to your calculations if you do not need to. Someone who edits the jump_height is most likely aware that -1 points up. No need to hide that fact. 2) It is nice to know the unit of the time by looking at the variable name. Someone who edits the variable does not have to guess.
Although I find this constructive, I think the first one is a matter of preference. I would much rather see positive values in my exports than having to add that - all the time.
I think this is the best video for getting the jump right, with it allowing you to control both the height and the time to reach the height. I think using the default gravity often slows down the jump too much as you reach the peak. One thing this doesn't do is allow you to "short" the jump by just tapping and letting go, or do the jump to full height by holding the button. I got this added in 3D using the following line under _physics_process(delta), and I think it would work in 2D if you reverse the signs: if Input.is_action_pressed ("jump") == false && velocity.y > 0: velocity.y -= 1 You can replace the velocity.y -=1 with whatever deceleration formula you want. You can also add a terminal velocity for your character by adding the following under your _physics process: velocity.y = clamp(velocity.y, -100, 100) replacing the 100s with whatever variables you want to use as the min and max velocity. This makes it so your character's fall speed will not increase indefinitely and eventually become constant. Otherwise you may find your character falling way too fast from big heights.
I know this is an older video so i probably wont get a reply, but if i move the menu anywhere other than the starting position, the cursor becomes wildly out of sync with the position of the menu. Leading it to "dissapear" but still being functional. Any help?
@@Shuhkky The property on control nodes should be rect_global_position. In any case it's hard to know what the exact issue could be without seeing your setup. Can you send some screenshots and a description on the github gist linked in the description?
Spent an hour trying to figure out how to set up Raycasting, only to find this channel and have every question answered concisely and simply. Thank youuuuuuuuu and also I love your animations they're adorableeeeeeeeee
@@SantaAzulCTZN You'll need to check if the player is on the ground. CharcterBody already has a method for this (is_on_floor). If your character isn't on the ground, don't modify their horizontal velocity (velocity.x) at all in the physics update
For those doing this in 3D and your jump height is inconsistent: Make sure this line: [return jump_gravity if velocity.y < 0 else fall_gravity] Is now: [return jump_gravity if velocity.y > 0 else fall_gravity] Also just generally make sure you are applying negative values to velocity.y for gravity...not positive. One wrong sign will mess up the whole thing.
@@retexcrafted does it work on mac? I dont want to use rpg maker because all the games made in it look the same, but it would be interesting to see how its code is set up
@@dungeoncorporation yes the newest rpg maker (RPG Maker MZ) works on mac I believe it is paid but its consistently on sale so that's that and have you played omori? that game used it so as long as your willing to make sprites it will be more than sufficient for making it look like its own thing. as for coding its pretty intuitive you wont need to code much but when you do its just basic Javascript
Good evening @Pefeper ! First of all, I wanted to thank for the tutorial, it really helped me out on creating the Pause Menu and part of the Settings Menu for the game im currently trying to make, and I wouldnt be able to have a stylish pointer if it wasnt for the help and knowledge that one could have through this video (my many thanks). However, it seems like, after I press the button assign for confirmation on the Resume Button, I bring up the Pause Window again without having to get the Menu back up again with the Start button, which means that while I hide the menu along the pointer/cursor, the cursor/pointer can still access to the menu and bring it back up again. I tried using the paused() function on the Pointer/cursor in an attempt to not only hide the Pause Menu and the Pointer/cursor, but to make the Pointer/cursor unable to be used unless the Pause Menu gets backed up to the screen by pressing Start/Escape, but that didn't worked. Any advice or tip to solve this(Make the Pointer/Cursor not able to Select a Label/deactivate it and activate it again) if I may ask? PD: I hope the week and overall, 2024, is going well for everyone.
I think there's a lot of ways you could solve this, but the simplest would be to keep a boolean variable on the cursor script named something like is_active. At the beginning of process(), check if it's false and, if so, return from the function before processing input. Then just set that variable to true when the menu is active, and set it to false when it's not
@@Pefeper Thank you very much! By creating a boolean variable and using an if conditional on process() function(if true, run the rest of the present code in process(), if false, pass) i was able to not let the pointer keep going down or pressing the buttons once the pause menu was hidden. I wouldnt be able to do it without your help. Thsnk you very very much Mr. :pray: Something mow im working on is to be able to fix some issues im having with the Settings Window, since once in Settings, if we press on Back button, it goes to Pause Menu yet, while it can detect us of pressing Setting Button, no longer it shows said Menu back up. But yeah, again...thanks...without your hell k wouldnt be able to fix this nor advsnce, i hope u keep having a fantastic week
How can i get a collision on the exit of a collider? Im trying to make accurate bullet penetration but i need to know when does the raycast leaves the collider that it first hit. So i thought relaunching a raycast at the collision point of the collider, just a bit inside it, in the same direction, but i cant make it detect when it leaves the collider? It seems it only detect entering a collider. How can i make it consider exiting a collider as a collision?
I'm back again to talk about refactoring this to work specifically with Godot's inbuilt focus for control nodes. I noticed every control node can specify it's neighbours, so if you're making a bunch of controls and you don't want to keep track of numbers, but update using the Focus tab, you can grab the nodepath as a text string using focus_neighbour_DIRECTION. makes for some short code too, as below; extends Control @export var menu_parent:Node @export var current_lbl:Label @export var cursor_offset: Vector2 @onready var path_pre:String = menu_parent.get_path() @onready var new_focus:String func _ready(): set_cursor_from_focus(current_lbl) func _process(_delta): var new_focus_node: Node if Input.is_action_just_pressed("ui_up"): new_focus = path_pre + str(current_lbl.focus_neighbor_top).trim_prefix("..") elif Input.is_action_just_pressed("ui_right"): new_focus = path_pre + str(current_lbl.focus_neighbor_right).trim_prefix("..") elif Input.is_action_just_pressed("ui_down"): new_focus = path_pre + str(current_lbl.focus_neighbor_bottom).trim_prefix("..") elif Input.is_action_just_pressed("ui_left"): new_focus = path_pre + str(current_lbl.focus_neighbor_left).trim_prefix("..") else: return new_focus_node = get_node(new_focus) #print(new_focus_node.name) if current_lbl != new_focus_node: set_cursor_from_focus(new_focus_node) current_lbl = new_focus_node #prints("changed node: ", current_lbl) func set_cursor_from_focus(focus:Node): global_position = Vector2( focus.global_position.x, focus.global_position.y + (size.y / 2) ) - size/2 - cursor_offset
just figured this out recently but in case anyone has this issue where the character teleports to the jump height rather than jumping normally, you just change: velocity.y = get_gravity() * delta to velocity.y += get_gravity() * delta this worked for me in a 3D game, idk if it does the same on 2D (itll maybe turn the jump into a really high jump so you might need to tweak the numbers a bit-) great video btw it helped me a lot!
Bro I wanted this but with walking/running action instead, I wanted to be able to specify how long until the character reaches max velocity and (after the player let go of the run button) how long until the character loses all its velocity
for my game, i did this: direction is either -1, 0, or 1, depending on the state of the input axis for movement in the ready function, set accel_rate to be top_speed / acceleration_time, and the same with decel_rate and deceleration if direction != 0: velocity.x += accel_rate * direction * delta velocity.x = clampf(velocity.x, -top_speed, top_speed) else: if velocity.x > 0: velocity.x -= decel_rate * delta velocity.x = max(velocity.x, 0) elif velocity.x < 0: velocity.x += decel_rate * delta velocity.x = min(velocity.x, 0) move_and_slide()
Thanks for the tutorial! I took changing which container I was in as a home task with vboxes; if the cursor ever tried to move left or right, i'd move the Index of the current parent along one in an exported array that was arranged so that the 0th index was the left-most box. if there wasn't a box to the right, i'd jump back to the 0th index box. after that, if the cursor index was too big, i'd make it jump down to the child count -1 in the new parent. i'm sure there are more elegant solutions, but i doubt i'm ever going to need to jump between umpteen vbox/ hbox and gridbox menus just yet.