# What is the equivalent of move_toward for a float value?

Attention Topic was automatically imported from the old Question2Answer platform.

I want to increase/decrease a CollisionShape2D circle’s radius gradually and up to a min/max limit and honestly i have no idea how, trying to use clamp and move_toward but the latter doesn’t work with float values (which the radius is)
So is there something like move_toward for float values and if not, then how do i go on about this?
Complete beginner to godot, gdscript and coding in general and just trying to get out of tutorial hell, so go easy on me.
` if Input.is_action_pressed("Sprint"): speed = 150 soundBubble.shape.radius = soundBubble.shape.radius.move_toward(8.5, 60.0, 1.0) if Input.is_action_just_released("Sprint"): speed = 90 soundBubble.shape.radius = soundBubble_StandingRadius #want this to be a gradual change as well`

Have you looked into using a Tween?

Ertain | 2021-10-10 04:27

AnimationPlayer can animate any property.

Thanks for reminding me, but it wouldn’t work for this exact mechanic since multiple actions will be affecting that radius (shooting/running/sneaking) and it would get very messy that way with an animation player.
I simply want to change the radius by a value with an upper/lower limit.
for now i’m using a clamp to keep the radius between two values however its just a band aid solution and i need something like move_toward that i can use with the radius.

DuskWeaver | 2021-10-10 20:50

Linear interpolation.

yrtv | 2021-10-10 21:10

Yep, lerp is what i was looking for

DuskWeaver | 2021-10-11 23:21

I am looking into lerp(), and it is not the same. It requires a weight which goes from `0` to `1` and what I have is the step length, which is the increment per second. I don’t know how to do the transformation

d2clon | 2023-02-17 20:39

``````func move_toward(actual:float, to:float, delta:float):