Search Unity

On Rails Running/platform game Pathing

Discussion in 'Scripting' started by Ranger3d, Oct 5, 2012.

  1. Ranger3d

    Ranger3d

    Joined:
    Oct 5, 2012
    Posts:
    1
    I have attached an example picture depicting some of the concepts of what i am trying to achieve.

    The player/object is constrained to a path the Green lines in the image, The player should be able to switch to the nearest path/track/road in the direction he intends to go,
    The player object speed, is controlled by the game/enviroment and not the Player him self
    EG:
    Pressing ( D ) key would tell the player to jump right, over the gap onto the next platform and attach to that path, however he can still jump if there is no path/road/track there but he will fall into the Death zone/Out of bounds area.

    I have been racking my brain at trying to find a solution to these Pathing issues and such, i am inexperienced to some degree and im not sure if im looking for the right things or what to do to achieve the solution. Mainly in terms of the pathing and switching solution.

    I am not sure what to do at this point.:(

    I hope some one out there has a solution to this to put me on the right (path :D).
     

    Attached Files:

    Last edited: Oct 5, 2012
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    First and foremost you need to solve the problem of attaching to a spline (you mention supporting curves).

    That's your FIRST problem.

    I recently posted in a thread about such a thing... lets see if I can find it.

    brb
     
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    Here found it:

    http://forum.unity3d.com/threads/15...ovement-axis?p=1031589&viewfull=1#post1031589

    So in it I talk about sticking to a spline and showed some examples in another engine where I did it.

    I'd like to mention, you may be able to adapt CustomJoint to help in restricting to the spline in the x and z axes, while leaving y free for jumping.


    Once you get splines down, then it's just a matter of jumping from spline to spline. Note that even in those gaps there (where you can fall) there's still a spline... there's just no floor. You should have full paths the entire way.

    To jump spline you just change the current spline, release the clamp to the spline, animate moving to the new spline, put clamp back on, and proceed.

    This finding the near spline could be done numerous ways.

    * all splines do not intersect and are always in the same order front to back... you just have an index position in the list of splines, grab the one before or after in the list.

    * splines intersect, you have intersect points defined, and a look up table to know in what order the spline is at a given point, that's your index, done....

    * project the location in the spline you are, and would be on each other spline (you could intersect the splines on an intersecting plane to get these). Project them onto the vector that describes depth at that location (camera forward probably or something). Order the splines like this from nearest to furthers, indexing as you sort, remembering the spline you're on when you sort. Now you have an index, done...




    Note - I like option 2.

    You can define regions along the splines. Each region defines the indexing order. This acts as your look-up table.

    This same look-up table can store other information too. Like how you jump from spline to spline. For instance you may want to do a flippy over to the other spline in this area, but another area you may want to do a duck and roll. You can get creative... like a lava level where you spray water on the ground to quickly create a walk path over... walk across it, and then it melts and crumbles away.
     
    Last edited: Oct 5, 2012