0 votes

Godot version 3.2 BETA 1


I am trying to find a way to scale the movement of a KinematicBody2D so that it behaves the same on different screen sizes. Currently, I am finding that a KinematicBody2D moves at different speeds depending on the screen size.

For example, I am creating a pixel art game where my "game" resolution is lower than the screen resolution. My game is 288w x 512h (portrait). On a mobile screen of 1080 x 1920, my artwork needs to be scaled up by 3.75 times. I could do this by simply scaling the viewport, but I find this gives choppy movement since the object is moving in steps of 3.75 pixels (maybe 4 with pixel snapping). Instead, I have chosen to scale the artwork and maintain the screen resolution. This gives really smooth movement, but the results are inconsistent.

I thought that simply multiplying the vector by the scaling factor would result in moveandcollide behaving the same on all screens but it does not. A test object moving from one side of the screen to the other, is significantly faster on the 288x512 window within Godot, than the 1080x1920 mobile device screen.

In essence, I need the object to move 3.75 times faster on the mobile test device, than it does in the Godot test window because it has to cover 3.75 times more distance in pixels. If anyone has any thoughts on how I can do this, or has an idea where I may have tripped up, I really would appreciate it.

Thanks for taking the time to read this essay! :)

in Engine by (370 points)

Good day! This is an interesting idea.

1 Answer

0 votes

It turns out, you can scale the movement... but you need to use move_and_collide inside the _physics_process(delta) function and NOT the _process(delta) function.

My mistake, I need to read the docs more carefully XD


by (370 points)
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 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 webmaster@godotengine.org with your username.