56dev
November 23, 2024, 10:38pm
1
Godot Version
4.3
Question
so as the title says, the movement of the player itself is not jittery, only the movement of the party members are. see vid:
it’s like the arrows jump forward a pixel when moving, but then bounce back at the end.
any idea why this is?
camera process mode is PHYSICS
both snap 2d transforms to pixel and snap 2d vertices to pixel are off.
the movement code of both the player and the party members are the same, they are both in physics_process
, and their SPEED
is the same.
if self.global_position.x != true_position.x or self.global_position.y != true_position.y:
self.global_position.x = move_toward(self.global_position.x, true_position.x, SPEED * delta)
self.global_position.y = move_toward(self.global_position.y, true_position.y, SPEED * delta)
physics_interpolation is on and physics_jitter_fix is 0. I tried setting them to off and 0.5, respectively, and the issue only got worse.
How are you calculating true_position
?
56dev
November 24, 2024, 6:23pm
3
for the player, true_position
is set as 8 pixels up, down, left, or right, depending on player input.
for the party members, their true_position
is set as whatever the global_position
of the member linked to them is, before the latter starts moving.
for example, the player is linked to the last party member (the party member directly behind it), so if the player’s true_position
changes while its global_position
is (0, 0), this is sent to the member behind it so its true_position
is set to (0, 0)
the code in the player looks like this:
true_position += direction_to_move_in * PIXEL_INTERVAL
true_position_changed.emit(global_position, true_position)
the true_position_changed
signal is sent to a PartyManager
, with the following code:
##SIGNAL RECEIVER
func _on_player_moved(current_global_pos, new_true_pos):
_move_party(current_global_pos)
func _move_party(new_pos):
if len(party_members) == 0:
return
party_members[-1].move_to(new_pos)
and each party member is linked to the one behind it.