MoveToward constant speed

Hey guys,

I’m having a real hard time with this. I am drawing a line of waypoints by mouse input, and the character follows it, starting at mousedown. What I need to come up with is a way to set the speed based on either pixels per second (approximately), or percentage of screen width per second.

What makes it difficult is that since the character is following the waypoints as you draw them, there’s no way to calculate the total distance, and thereby find the speed. Also, since the waypoints are drawn per frame, they’re not an even distance apart.

Anyone have any ideas? I’m using transform.MoveTowards to set the speed, unless there’s a better way?

@sandworm
I’m not a professional scripter, but I theorize you can use the Vector3.Distance to calculate the distance from point a to b (and b to c and so on), and put the waypoints in an array. That way, you have access to the distance from individual points AND the total length of your pathing.

I hope that helps with the brainstorming. Best of luck,

-S