move_and_slide gives different results in different android devices

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zen3001

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():
:bust_in_silhouette: Reply From: tastyshrimp

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.

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

zen3001 | 2019-12-20 15:30