Calculate Duration [NPC]

Hey, I’ve been trying to figure this out but I just can’t get around it…

How would I go about calculating how long it would take an NPC to get from PointA to PointB.

1 Like

If you know speed, you can get the distance between pointa and pointb and just do simple calculations.

Everyone knows Speed = Distance/Time therefore with a little bit of algebraic manipulation, Time = Distance/Speed

1 Like

Well, take the total distance and divide it by the speed. For example, 50 studs at 5 studs per second would take 10 seconds. If you’re using pathfinding, just do this for each waypoint and add up the time.

Stated better here

1 Like

Yea Ive calculated the distance with .Magnitude, I’ll try this thank your for your help.

Thank you for this.

local Distance = (HumanoidRootPart.Position - Target.Position).Magnitude / Humanoid.WalkSpeed