#why jump doesn't work while sprinting ?
1 messages · Page 1 of 1 (latest)
why in some games we cant jump while sprinting ?
i tried multiple tutorials but still
look at this, from a youtuber ```func _ready():
#set move variables, and value references
moveSpeed = walkSpeed
moveAccel = walkAccel
moveDeccel = walkDeccel
hitGroundCooldownRef = hitGroundCooldown
jumpCooldownRef = jumpCooldown
nbJumpsInAirAllowedRef = nbJumpsInAirAllowed
coyoteJumpCooldownRef = coyoteJumpCooldown
func _process(_delta: float):
displayProperties()
func _physics_process(_delta : float):
modifyPhysicsProperties()
move_and_slide()
func displayProperties():
#display properties on the hud
if hud != null:
hud.displayCurrentState(stateMachine.currStateName)
hud.displayDesiredMoveSpeed(desiredMoveSpeed)
hud.displayVelocity(velocity.length())
hud.displayNbJumpsInAirAllowed(nbJumpsInAirAllowed)
func modifyPhysicsProperties():
lastFramePosition = position #get play char position every frame
lastFrameVelocity = velocity #get play char velocity every frame
wasOnFloor = !is_on_floor() #check if play char was on floor every frame
func gravityApply(delta : float):
#if play char goes up, apply jump gravity
#otherwise, apply fall gravity
if velocity.y >= 0.0: velocity.y += jumpGravity * delta
elif velocity.y < 0.0: velocity.y += fallGravity * delta``` even in this while run and jump together jump sometimes get stuck
**
**var auto_bunny_hop is false and im holding = w + sprint + space in this video, and jump doesnt work if sprint is held first , if i enable auto hop then it doesnt get stuck but then i dont need to hold it just press once the jump button but i want holdable
Thanks for your time and help 🙏
why jump doesn't work while sprinting ?
This code doesn't contain movement logic, it only saves some previous frame values
Judging by the naming and lack of @onready, it was written by a unity programmer. Is the movement code in another node, a "movement component" or something?
this is the github repo https://github.com/Jeh3no/Godot-Simple-State-Machine-First-Person-Controller
Oh god
This is too messy for me to analyse quickly, you might have to rubber duck through the machine states to figure out what's preventing jump while running
Is this your GitHub repo?
No it's of a youtuber !
Does the example scene that is provided in the repo work correctly?
If it works there with jumping+sprinting at the same time like you say, then you should go look and find the difference between that scene and the one you created, and there you will find your issue
So it doesn't work in the provided example?
Yes