0 votes

for some reason, when I install the game in different samsung mobiles, the movement behaves completely different, especially the jump function for some reason.

here's the movement code I have:

var left = false
var right = false

var double_jump = false

var vel = Vector2().ZERO

var speed = 500

    if is_on_floor():
        if Input.is_action_just_pressed("up"):
            vel.y = -21
                double_jump = true
    elif Input.is_action_just_pressed("up") and double_jump:
        vel.y = -21
                double_jump = false
        vel.y -1

    if left:
        vel.x = -5
    elif right:
        vel.x = 5
        vel.x = 0

    move_and_slide(vel*delta*speed, Vector2(0, -1))

and the touchscreen buttons are under a canvaslayer, that's instances as a child of the player's kinematic body(the kinematic body is also the root of the player's scene), here's the script for those:

onready var p = get_parent()

func _on_LeftKey_pressed():
    p.left = true

func _on_RightKey_pressed():
    p.right = true

func _on_LeftKey_released():
    p.left = false

func _on_RightKey_released():
    p.right = false

func _on_UpKey_pressed():

func _on_UpKey_released():
in Engine by (304 points)
edited by

1 Answer

+1 vote
Best answer

I'm no expert when working with mobile phones but it might be because you are doing the move and slide method inside _process instead of inside the _physics_process where it should usually be located, since move_and_slide should happen in the physics step.

by (572 points)
selected by

yep, that seems to do the trick, allways wondered what difference physicsprocess would make. thanks

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.