Godot Version
4.7.2
Question
I have a pretty simple movement script. One that just moves the character around at a specified speed in “units” per second. My player object is attached to a node that acts as a root transform - translating world space into screen space by translating half the screen dimensions and scaling to a pre-configured “pixels-per-unit.”
The problem is that if I don’t multiply my velocity by the global scale, the speed is treated as pixels per second and not “units” per second. I could be misunderstanding the specification of the CharacterBody, but this seems antithetical to the idea of a hierarchical transform.
extends CharacterBody2D
@export var speed : float = 1
func _physics_process(delta: float) -> void:
var motion := Vector2(Input.get_axis(&"pc.move.left", &"pc.move.right"),
Input.get_axis(&"pc.move.up", &"pc.move.down"))
velocity = motion.normalized() * speed
// movement speed is incredibly slow without the code below
// velocity.x *= global_scale.x
// velocity.y *= global_scale.y
move_and_slide()