I have a script for a basic flappy-bird movement.
But even if I comment out the jump function and gravity function, the move_and_slide method still makes the bird go up
This is the relevant code:
func _physics_process(delta):
if not is_on_floor():
#velocity.y += gravity * delta
pass
if Input.is_action_just_pressed("jump"):
jump()
move_and_slide()
func jump():
#velocity.y = JUMP_VELOCITY
pass
the real problem I think is that something else is changing the bodyâs velocity because when I print it to the console is like this (95.85297, -6.973267)
Are you using a Character body or a Rigid body? Move and slide does not work on a rigid body and a character body does not have a way to set linear_damp
My fault here, failed to mention flappy is a Characterbody 2D, so (I think? Just looking at the docs) it doesnt have linear_dump
also, dunno if is gonna help, if I change the motion mode to floating flappy only goes upwards, but if I change it to grounded it goes upwards and towards the left
You donât need to do anything with the motion mode. I just tested the code you posted with jump and gravity commented out and it works as expected. The body does not move.
Unless I see your project, itâs diffusion to find the bug.
This forum was under a quite heavy spam attack, so we now require posts of new users to be approved by staff. This changes automatically once you have interacted a bit with the community (and you reach trust level 1 because of that). I have set your trust level to 1 manually right now since you are clearly human
Ill try recoding the script from scratch but other than that I havent got any more ideas, maybe ill paste the scene in a new project and see if the issue persists
I know what doesnât work, the problem was in another script entirely, the problem is I dont really know why it doesnât work.
Thank you all for your patience and sorry that I didnt really give the correct information