# Working on a train system but I don't know how to stop it in a specific point.

**URL:** <https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint\
**Created:** [August 14, 2023, 2:13pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682 "2023-08-14T14:13:07Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 2:13pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/1 "2023-08-14T14:13:08Z")

</div>

Hello guys!

So, I am working on this train system with stops, but I don’t really know how to make it stop on a specific point. I did a prototype that works, but is not 100% accurate, I need help.

Let me explain how the system works:

1. The train will move along a spline which is generated procedurally.

2. The speed is handled by a timeline:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/0/100d9c1ab2a433f3e7e635fa60ed0eef7f9063bc.jpeg)

1. The movement is handled by the event tick. The starting distance is 0 and if it is lower than the spline length, the move function will be fired to move the train:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/b/5cb54c444a8209e52be7ae1967fe0e74680fd39b.png)

1. There is also a BP\_Station, with a collision box, and every time the train overlaps it, the “STOP” event will be fired and speed will decrease thanks to another timeline:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/3/a930e00e44f03980672ad08ea6fad76cba67e87a.png)

Now, my problem is that sometimes the train will stop at different locations, even if the station’s collision box is always there.  
Do you have any suggestion to make my train always sto at the same spot? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 14, 2023, 2:49pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/2 "2023-08-14T14:49:55Z")

</div>

This all sounds like a real train to me 🙂

If you really want it to stop at an exact spot, then you need to switch all of this stuff off on overlap, and use _another_ timeline, to take it from the overlap point, to the stop point.

---

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 3:04pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/3 "2023-08-14T15:04:18Z")

</div>

Thanks man! 🙂

So you would suggest to add another timeline to the BP\_Station whenever the train overlaps the box collision, is that correct?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 14, 2023, 3:23pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/4 "2023-08-14T15:23:02Z")

</div>

Yes. It’s too difficult to do with your tick method.

So when it hits that buffer, just totally switch to a new TL, that will make sure it always lands in the right spot.

---

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 3:26pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/5 "2023-08-14T15:26:51Z")

</div>

Mmmmh ok, so I might add a bool to the train BP to switch off the movement logic and then add this new timeline in the station BP.

What is not totally clear to me, is how to setup this new timeline to make the train arrive to a specific spot.

Sorry for all these questions, and thanks for your patience! 🙂

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 14, 2023, 3:30pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/6 "2023-08-14T15:30:56Z")

</div>

You have it’s current location ( on hitting the box ), and the stopping location ( on the spline ).

So you can lerp between the two locations, using a TL.

---

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 3:32pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/7 "2023-08-14T15:32:56Z")

</div>

There is any way to get the location of a specific point on the spline?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 14, 2023, 3:40pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/8 "2023-08-14T15:40:00Z")

</div>

Not a location in space ( otherwise it will come off the spline ). Distance along spline, I meant.

---

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 3:40pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/9 "2023-08-14T15:40:25Z")

</div>

Awesome, thanks a lot.

I’ll try to make it work, thanks!!!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 14, 2023, 3:49pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/10 "2023-08-14T15:49:38Z")

</div>

You could use either of these, I think

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/a/aba2d3d9fb926d3d1835fa15d0e93f7a1520fb8b.png)

---

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 3:52pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/11 "2023-08-14T15:52:45Z")

</div>

Thanks, I was trying to make it work but I found a couple of issues.

First of all I created a new collision box on the BP\_Station, so on overlap it can take the location.

But the real problem is that I can take the distance of the train (there is a “distance” variable in BP\_Train), but I can’t do the same on the BP\_Rail. So I don’t really have a way to have the distance on the stop location.

I am looking for a different solution.

---

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 4:24pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/12 "2023-08-14T16:24:46Z")

</div>

Even getting the point index seems impossible. I am trying different approaches.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 14, 2023, 5:56pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/13 "2023-08-14T17:56:58Z")

</div>

When the train overlaps, you know it’s location, that’s one point. The other is also known, the station.

There’s a node called something like ‘nearest point on spline to world location’ ( _extremely_ approximate name, I’m not at a machine rn 🙂 )

Also, why not organize it so that there’s a spline point at the overlap, and another at the station.

Many options 😃

---

<div class="post-metadata">

**Author:** ![SpaceAce\_717](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spaceace_717/32/88713_2.png) [@SpaceAce\_717](https://forums.unrealengine.com/u/SpaceAce_717)\
**Post date:** [August 14, 2023, 5:57pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/14 "2023-08-14T17:57:57Z")

</div>

Awesome, I’ll search it, thanks!

---

<div class="post-metadata">

**Author:** ![PresumptivePanda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/presumptivepanda/32/1194593_2.png) [@PresumptivePanda](https://forums.unrealengine.com/u/PresumptivePanda)\
**Post date:** [August 18, 2023, 5:23pm UTC](https://forums.unrealengine.com/t/working-on-a-train-system-but-i-dont-know-how-to-stop-it-in-a-specific-point/1260682/15 "2023-08-18T17:23:23Z")

</div>

Hi there @SpaceAce_717,

This topic has been moved from **International** to **Programming & Scripting: Blueprint**.

When posting, please review the categories to ensure your topic is posted in the most relevant space.

Thanks and happy developing!
