Godot Version
4.2.2.stable
Question
I took a long break from game dev and am trying to come back, starting with moving my project over to Godot 4.2 from 3.5. I’ve been mostly successful so far, but I’m running into this strange issue where my player suddenly runs faster in the rightward and downward directions than in the leftward and upward directions. The strangest part about it is that it wears off after about a minute or so, more or less. In the video below, it’s at around the 42-second mark that it all starts going at the same speed. This is just using digital arrow keys on a keyboard, no analog control.
The recording above is using _process() for movement, running V-Sync, holding a max 60FPS, and using a 75FPS monitor. The output is showing velocity.length() each frame and FPS every second. As you can hopefully see, it’s clearly a magnitude of 90 units (while running non-diagonal) and 60FPS, consistently.
In addition to restarting Godot, I’ve tried messing with combinations of switching between _physics_process() and _process(), turning V-Sync on and off, using different monitors with different FPS limits (60 and 75), setting my max FPS project setting to 0, 60, and 75, and doing the same for the Force FPS project setting…until…(even weirder yet) all of a sudden that setting just completely disappeared. I swear to God, I was using it one second, then the next time I went into project settings, Force FPS is just not there anymore. Upon looking that up, apparently Force FPS isn’t supposed to be in Godot 4 at all anymore, so it’s kinda creepy that it was there in the first place, then just made like a ghost. I’m fairly certain it was set to force 60FPS prior to this issue starting, and I had set it to 0FPS right before disappearing. So now it’s stuck in a different value.
None of these combinations solved it, only made things worse in some cases (turning off V-Sync made it so my player wouldn’t move at all, besides rotating the direction he was facing, for instance). In some cases however, while Force FPS was still available, I found that running on the 75 FPS monitor resulted in no issues at all, but dragging the window over to the 60FPS monitor had the results shown in the video. Now, it is only ever how it is in the video, no matter the monitor FPS.
Anyway, here’s all the code that should be affecting it:
extends CharacterBody2D
var state = MOVE
var input_vector = Vector2.ZERO
var roll_vector = Vector2.DOWN
@export var ACCELERATION = 500
@export var MAX_SPEED = 90
@export var FRICTION = 500
enum {
MOVE,
}
func _ready():
animationTree.active = true
func _process(delta):
match state:
MOVE:
move_state(delta)
print(velocity.length())
func move():
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
set_velocity(velocity)
move_and_slide()
velocity = velocity
position.x = round(position.x)
position.y = round(position.y)
func move_state(delta):
move()
if input_vector != Vector2.ZERO:
animationTree.set("parameters/Idle/blend_position", input_vector)
animationTree.set("parameters/Run/blend_position", input_vector)
animationState.travel("Run")
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
>
else:
animationState.travel("Idle")
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
Has anyone ever dealt with this strange behavior? Any tips?