Tweening using custom speed

Hello! I’m making a tower defense game, and I’ve had an issue that could easily be solved another way. So I did that way, and the original issue was I was tweening a part and the speed would be the distance * the base speed * the enemy speed but the enemy speed should get higher and get faster but it slows the faster the enemy speed so how would I fix this?

Sorry if this is not what you want but if you want to make the tweening speed based of the distance u could use magnitude between the root and an endpoint then use the popular physics formula (t = d/v)

what do you mean, I have the distance which is the next point, and the enemy.pos magnitude but that doesn’t explain why the higher the speed the slower the enemy is

The closer the enemy is to the distance, the slower he will be, if u want it to stay constant do that

local distance = (enemy.Position - point.Position).Magnitude
local enemySpeed = 2
local tweenSpeed =  distance / enemySpeed
-- then use tweenSpeed when creating the tween

This worked thanks, now I just need to re-adjust the speed! :grinning:

1 Like