Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get nearest point to a world object
#1
Rainbow 
Hi, I would like to place stations along a track and then if a train is scheduled to stop at the station next, find the nearest control point to that station, and then eventually set connections properly to make sure the train will go to the right path that this specific cp is on. I imagine this last bit will get more complicated if there are several connections before this control point as it'd need to calculate a full route not just switch a single path A or B. 

So is the easiest way to do this to make a new control point when a station is placed so a station will always be sat on its own control point which could be stored as a value the station itself, or is that not possible?

If it's not possible can I get the nearest control point based on the x,y,z of the station gameobject (which is just an object in the world its not related to the spine or anything)

And then how can I talk to the connections to make sure they are set in a way that will make the train choose the right path at a junction? Even at a basic level where there is only 2 paths A and B and it needs to choose a station on path A or B how would I set the connection to switch (or not) depending what it needs to do?

Sorry if that's sort of 2 questions in one! Any help is appreciated!

Now that I think about it maybe I don't need the nearest CP at all maybe I should just set the station to the spline it's on when placed? So if it's collider (trigger) is touching spline B it's set to that, is that possible even though the spline doesn't have colliders on it?

But then i would still need to know how to make sure the train follows the right spline to the spline that station is set to when it comes to a connection somehow...
Reply


Messages In This Thread
Get nearest point to a world object - by jamesunity - 07-13-2020, 11:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting Distance from a World Point zorksox 3 5 04-16-2024, 07:30 PM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
  Removing the objects behind an object alms94 6 6 12-06-2023, 09:31 PM
Last Post: _Aka_
  Connection "next' control point jh092 3 15 11-22-2023, 11:47 AM
Last Post: _Aka_

Forum Jump: