Hello!
I'm trying to move a player around a grid, using a tween to animate the translation property. It's working well, except for the case when the player still has the input key held down, and here I'd like the movement to smoothly continue - instead, there's a slight stutter when restarting the tween, and I was wondering if there was anything I could do to avoid it?
I think the underlying issue is that e.g. asking a tween to animate a value between 1 and 2 will produce frames where the value is 1 at the start, and 2 at the end - when I chain that with a tween between 2 and 3, I get a '2' value used for two subsequent frames, where the tweens join.
For example:
extends Spatial
var tween = Tween.new()
var val = 0.0
func _on_Tween_all_complete():
tween.interpolate_property(self, "val", null, val+1, 0.1)
tween.start()
func _ready():
add_child(tween)
tween.connect("tween_all_completed", self, "_on_Tween_all_complete")
tween.interpolate_property(self, "val", null, val+1, 0.1)
tween.start()
func _process(delta):
print(val)
The list of values printed show duplicate values on the integer boundaries - I'd like to set it up somehow to avoid that, so there's only one integer value there instead. What's the best way to do that?
I guess I could set the initial value to be val + (a bit)
... but how would I determine how much to add? Would I need to keep track of the _process delta
values?