Skip to content

Commit 738db14

Browse files
committed
player: Invert jump velocity parameter & adjust range
When the player jumps, the y component of their velocity is set to jump_velocity. In Godot, up is negative. So velocity.y must be set to a negative number. But I don't think this means that the jump_velocity parameter needs to be negative. And certainly it doesn't make sense for its range to include jumping *downwards* by setting it to a positive number: I have tested this and as expected it doesn't actually work. Invert jump_velocity: set velocity.y to its negation when jumping. Adjust the default value accordingly. Change the range to 0–2000 rather than -1000–1000.
1 parent a0c29b4 commit 738db14

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

scripts/player.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const _PLAYER_ACTIONS = {
3434

3535
## How high does your character jump? Note that the gravity will
3636
## be influenced by the [member GameLogic.gravity].
37-
@export_range(-1000, 1000, 10, "suffix:px/s") var jump_velocity = -880.0
37+
@export_range(0, 2000, 10, "suffix:px/s") var jump_velocity = 880.0
3838

3939
## How much should the character's jump be reduced if you let go of the jump
4040
## key before the top of the jump? [code]0[/code] means “not at all”;
@@ -107,7 +107,7 @@ func _on_gravity_changed(new_gravity):
107107

108108

109109
func _jump():
110-
velocity.y = jump_velocity
110+
velocity.y = -jump_velocity
111111
coyote_timer = 0
112112
jump_buffer_timer = 0
113113
if double_jump_armed:

0 commit comments

Comments
 (0)