Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curvy 2.5D Platformer - Detaching from Spline when Jumping
I'm currently hacking about/toying with making a 2.5D platformer using curvy splines to create the path for the player to follow.

So far I've put together a control system that moves the player horizontally on the spline and uses a modified version of the Endless Runner example to allow the player to jump and connect to new splines if there is one above them or if they fall off one spline path onto another.

However I'm stumbling on how to set the controller up so that the player can jump from one end of a spline onto another i.e. across a horizontal gap between two separate splines. At the moment my control system stops the player at the end of the spline and doesn't allow the jump to continue beyond the last control point. My current idea is to have the player object break it's connection to the spline it has just been on while somehow continuing to move in the direction of the jump and searching for a new spline below the player object to attach to.

I was just wondering if anyone had a better idea or suggestion on how to implement a system for handling jumping between splines or had an implementation that they could share.

Your idea sounds good. If you know the next spline, you could store that information at the last CP GameObject and let your controller do a quick range-check against the new spline's starting CP. Then, when over the new spline, "hook" the controller back onto track.

Having worked on my idea of modifying the Endless runner script to enable me to detach at the end of splines, I abandonded that approach as it wasn't performing as I wanted and the code was becoming convoluted.

So I went back to basics and cretaed a new rigibody based approach which allowed me to have a player object following splines as a guide/rail while under the control of the Unity physics system and thus able to jump and disconnect/reconnect to the spline paths at will.

However I'm encountering an odd issue when I try to have the player object follow a sloped curve i.e. a curvy spline where the control points curve up or down in the Y axis, the rigidbody/player follows the curve of the spline fine but it is dragged towards the first control point without any user input. And if you try to move away from the first control point, it feels as if the rigidbody is connected by a rubber band to that control point, in other words you can only move so far before the rigidbody slows and struggles to move any furhter away from the first control point.

If I disable the curvy spline components being used as a guide/rail under slope, then the rigidbody behaves as expected i.e. it can freely move along the curved surface. I therefore suspect that my issue is arising from how I am setting the position of the rigidbody on the slope using the curvy spline guide. At present, the rigidbody script adopts the approach of the endless runner script and casts a ray downwards to detect a collider attached the the curvy spline. It then uses the InterpolateFast method to get the X and Z position for the the current TF of the spline and applies these to the rigidbody, with the Y position taken from the rigidbody to enable it to stay on the surface of the slope.

However I'm at a loss as to where I'm going wrong so any advice/suggestions would be appreciated.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner's questions - Closest spline & closest point on spline nehvaleem 5 71 01-20-2021, 09:37 PM
Last Post: _Aka_
  Vector3 array from spline Philip 3 119 01-09-2021, 02:16 PM
Last Post: _Aka_
  Input Spline Path Material Option not suported Andrei 3 212 12-15-2020, 12:20 PM
Last Post: _Aka_
  Object enter spline from collider. camelart27 13 558 12-02-2020, 06:22 PM
Last Post: Zhavier

Forum Jump: