Open CodeLazier opened 3 weeks ago
That's expected behavior, you'd either need to to turn off physics interpolation specifically for that AnimatedSprite2D: Or reset in manually in code after the "teleportation":
func _test()->void:
if Input.is_action_just_pressed(&"ui_accept") && !animated_sprite_2d.visible:
if _vel.x > 0:
animated_sprite_2d.position.x = 30
elif _vel.x < 0:
animated_sprite_2d.position.x = -30
animated_sprite_2d.show()
animated_sprite_2d.reset_physics_interpolation() # <-- Currently must be after `show()` see comments below.
animated_sprite_2d.play()
await animated_sprite_2d.animation_finished
animated_sprite_2d.hide()
Otherwise it interpolates with whatever its previous position was, meaning it possibly interpolates between (30, 0)
and (-30, 0)
, right after you're showing it.
Better visible with lower physics/common/physics_ticks_per_second
project setting:
Seems like documentation issue, should be solved by https://github.com/godotengine/godot-docs/pull/9738.
yes, turn off physics interpolation specifically for that AnimatedSprite2D, it's worked. but, animated_sprite_2d.reset_physics_interpolation(),the problem still exists
but, animated_sprite_2d.reset_physics_interpolation(),the problem still exists
Oh, indeed. Currently animated_sprite_2d.reset_physics_interpolation()
would need to be after animated_sprite_2d.show()
to take effect, see: https://github.com/godotengine/godot/issues/94736#issuecomment-2251369114. I've edited my comment.
(I've tested it before and it worked, so I must have moved the animated_sprite_2d.reset_physics_interpolation()
line closer to the "teleporation" code after pasting it in here.)
@lawnjelly @rburing Shouldn't is_visible_in_tree()
be changed to is_inside_tree()
in this check? :thinking:
https://github.com/godotengine/godot/blob/568589c9d8c763bfb3a4348174d53b42d7c59f21/scene/main/canvas_item.cpp#L377-L381
Tested versions
4.3 official
System information
win10
Issue description
Enable physical interpolation
Turn off physical interpolation
note:put the input response code into the _input and the ghost disappears.
Steps to reproduce
See example project
Minimal reproduction project (MRP)
t.zip