- Edited
I have a 2D drone I'm creating and I'm attempting to give it the illusion that it's bobbing "up and down" by randomly scaling it when a timer runs out. the problem is, when it scales it does so instantaneously which looks rather jarring. I've been looking into vector2.lerp() and have got it to stop giving error messages but my understanding of it is still a bit wonky. it still isn't smoothing the scaling any. here's my code and my theory as to why it's not working:
func _on_hover_timer_timeout():
var scale_value = randf_range(0.9,1.2)
var new_scale = Vector2(scale_value,scale_value)
scale = scale.lerp(new_scale,1.0)
I think what's happening is that because it's in the timer timeout, the "lerp" happens all at once, so it still looks like it's not scaling smoothly at all. I'm entering new territory here (I usually use animations for this kind of thing but as far as I know you can't do random values with those) so I appreciate any help I can get!
edit: my hypothesis was correct, but now I have new problems. I moved scale = scale.lerp(new_scale,1.0)
into process and now it's scaling non-instantaneously... except A: it's really fast no matter what I set the weight to and B:(never mind, I figured out the speed issue, it was just multiplying by delta that fixed it) the scale is a little too over all the place, sometimes it becomes invisible from getting so small. there must be something I'm not understanding right
edit again: I got the scale issue! it was a weird bug caused by my own logical error. basically I moved new_scale to the top of the script and initialized it there, which started it at 0,0 so when the hover_timeout function ran the first time it scaled the drone down to 0,0 before giving it a new number. I just have to make sure that function doesn't run until it has the right number the first time.
I figured it out myself somehow but I'm leaving this up in case someone has a similar problem in the future.