Android performance (simple sprite movement / no physics)

Godot Version

4.2.1

Question

I am struggling with understanding if this is normal Android speed/performance.

I am developing a simple Tetris clone, to target Android devices. In my PC, the piece (when in free fall) move so fast that I can’t even see it. When the piece starts its free fall, I just do:

piece.position.y += 40

and the piece shows instantaneously at the bottom of the screen. Which is fine/expected.

Now, when I run the same code in an Android device, the piece movement is quite slow and takes around 1 second to reach the bottom of the screen.

Intrigued, I created a very bare minimum project with a single sprite and the code (triggered by a button press):

Button pressed() sets the _fall variable to true.

func _process(delta):
	if _fall:
		move_down()

func move_down():
	var x = get_child(0)
	
	if x.position.y >= 1000:
		_fall = false
		return
	
	x.position.y += 40

The above gives me the same behaviour in Android: ~1sec for the sprite to reach down the screen…

Can anyone tell me if this is the expected performance for Android?

Is the only solution to that, making the sprite move more pixels at a time (ex. 80 instead of 40) ?

Thank you!!

At the moment your code depends on your device’s processing power and the frame rate. Most probably your PC can produce 200-300 or more frames per sec, while your Phone/Tablet is doing 30-60 frames. To avoid that you need to used delta.

You have to multiply your speed by delta.

x.position.y += 40 * delta

make sure to pass delta to your function.

move_down(delta)

func move_down(delta):

Also make sure to check the docs: Idle and Physics Processing — Godot Engine (stable) documentation in English

Good Luck!

1 Like

Hi.

Ah, that makes sense. Such a beginner mistake!

Fixed my code as you suggested.

I just read the docs page you sent too.

Thank you again

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.