Hey. I’m working on a custom movement engine that is basically 2D but I need to be able to shift the Y position sometimes. Would it be possible to lock the actor’s Y position to a spline but only when it is overlapping the spline? So far I have X Y and Z variables that plot the character in the world. The Y value is always set to 0 since it is a sidescroller. I basically want to be able to drive that Y value and give it the Y coordinate of a spline it is interacting with. Is that at all possible?
Sorry for the bump but I still cant figure this out.
Maybe something like this?
That’s not exactly what you describe… essentially, the level has a single spline mapped across it and “movement” actually sets the actor’s “horizontal” location to a distance along the spline. The player moves in “2D” according to the spline shape, which means fully 3D movement happens but it’s constrained to two axes of player control.
I also do something similar to what you describe in my game to make the player grind along spline-based rails when a detection primitive overlaps them, but that’s substantially more complicated, because in order to make it work you have to be able to accurately approximate the location OF the collision which splines cannot do natively (I can explain how I did it if that’s what you desire, but it seems like it might be too complex for what you’re doing).
It sort of sounds like you’re going for a Goemon’s Great Adventure type of thing, where the player moves according to splines but those splines might diverge so the player will need to detach and attach from them (e.g. if he goes to a higher platform, he will move rightward, but if he goes to a lower platform, he might start to turn clockwise and take a different 3D route).
Actually, what you do in your game would help with a later issue I might ask for. I want to diverge paths AND add grinding later on (I’m making a Sonic Engine for learning purposes) If you would be so kind as to explain it, it would kill 2 birds with one stone and I would greatly appreciate it.
Here’s a test of what I’ve done so far: