# Calculating speed based on travel distance

This topic is 2888 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello,

I have the following problem. There are two(or more) objects that follow a path through a level starting at different positions. Now those objects should theoretically be able to hit each other when they cross paths, no matter at what position in the level they started. There is a calculation i'am missing here to accurately set the speed based on the overall length of the path. Just setting the speed to pathLength*scale doesn't give correct results and the objects are missing each other.

Any help or pointer in the right direction would be appreciated.

Edit: Sorry i think i postet this in the wrong forum, could someone move this to Math and Physics ?

##### Share on other sites
I don't know if I understand you correctly, but I'll try to explain the answer to what I believe you are asking. It is quite simple actually.

Take a look at HelpfulPic.png, it names a few things of interest. First there is POI, a shorthand for Point Of Intersection. You must find the point of intersection between path 1 and path 2. Then there is len1, the length from the start of path 1 to the POI. Same with len2, the length from the start of path 2 to the POI. There is one variable missing though, time. You must set an arbitrary amount of time that you would like to pass before the two objects collide, for example 2.0 seconds or 4 minutes, etc. With these variables you can use the following equations:
 Object1_Speed = len1 / t Object2_Speed = len2 / t 

These two speeds will make it so object 1 and object 2 collide.

##### Share on other sites
Yea time it is what i was missing. What i forgot to say is that those two objects might start at different times(1-2 seconds difference), so i need to take this into account.
Thank you very much!

##### Share on other sites
t in the formula doesn't have to be the same for all objects it needs to be (tcollided - tstarted) aka how long this specific object was traveling.

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633659
• Total Posts
3013209
×