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
  Invisible Gizmos In Latest Curvy Splines orrenravid1 1 2 06-11-2024, 07:36 AM
Last Post: _Aka_
  How to get length starting from one spline to connected nth spline Dragon-3623 1 1 05-14-2024, 04:52 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  8.8.0 is live, and it improves Curvy Generator greatly _Aka_ 1 12 04-03-2024, 03:16 PM
Last Post: _Aka_

Forum Jump: