#why jump doesn't work while sprinting ?

1 messages · Page 1 of 1 (latest)

sick inlet
#

i wanna add smooth jump and sprint in FPS Shooter Controller

#

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 🙏

sick inlet
#

why jump doesn't work while sprinting ?

low hound
#

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?

sick inlet
low hound
#

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

sick inlet
lean glade
#

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

sick inlet
#

No

#

I didn't change the code

#

It's just the default

#

It's same in functionality

lean glade
#

So it doesn't work in the provided example?

sick inlet
#

Yes

lean glade
#

Then you have an issue with that addon and you should contact the author (eg: make an issue on the GitHub repo) to get them to fix their addon

#

Nothing we can help you with here, as we did not write the addon you're using