Help Me With This Spline Concept?

So I’ve been using the Character Movement Component for my game and as I understand because of the way the gravity works its hard to implement it going past 90 degrees etc.

I have a concept it mind that could potentially work in terms of faking this effect and I would like to help bring it to fruition

Basically we have a spline actor that is restricted to moving left and right on the X or Y axis we would also need this actor to be constantly following/mirroring the position of the character so the character can get on the spline at any point. This will fake the left/right movement of the character.

The Character will then follow the path of the spline moving forwards and backwards

Combining both of these motions would in theory fake the effect of the character walking/rotating on the surface of choice

I would like to know the best way of developing this in blueprint.

I have somewhat of an idea but my biggest problem is the spline actor

Here is a mockup to clarify.

268532-movement.gif

Any help would be appreciated thank you!

for the sake of discussion how about something like the following image to get started with. basically i created a actor that contains a spline component and a box collision. on begin overlap with the character we open a gate which enables tick to run (for testing purposes), end overlap closes the gate. so on tick we get the splines world position and then set its Y location based on the characters location, im not sure that this bit is actually needed but it was in your example so i went with it. then we get the rotation of the spline at its closest point to the player and set the players rotation.

im not sure if this is exactly whats needed or how it will work in your case but its a place to start and maybe begin the discussion.

Thanks that definitely set me in the right direction although I did encounter a couple more problems

I added a find location closest to world location along with rotation so the character could move along the spline.

1.Setting the world rotation is needed for the character to rotate properly along the spline but this then prevents the character to orient to its movement rotation which ruins the illusion.

2.Once the character walks on a spline with an incline it shoots forward I assume this is a problem with the velocity not being accounted for with the rotation of the spline and character Im not sure how to fix this.

3.Once the character is at a 90 degree angle on the spline it just freaks out I assume its a combination of the event tick trying to constantly place the character on the spline and the character itself falling off, I tried to remedy this by turning off gravity but this just made the character float away from the spline instead.

268569-splineerror.gif

[Heres the link to the blueprint][2]

Hi Jinkuu, I believe the character rotating like this when it reached 90 is because the spline doesn’t actually have a “rotation”. You can only get a trustworthy forward vector from a spline, the rest is calculated from that and its up vector. if the forward vector is equal to the up vector, it can’t get a cross product for the right vector. if your spline is always going to oriented this way try setting the up vector to be +y (or x maybe depending on the orientation) or you could maybe try to set the rotation of the spline points and lerp between them

Hi thanks for replying, I realized that the box collision didnt cover the entire spline which caused me to constantly fall off and on the box which caused the character to freak out, once I fixed this my only problem was the character shooting forward along the spline once it hit 90.

I tried setting the default up vector to the spline to +y but it only inverted the characters rotation.

Im not sure how to set the rotation of the spline points and lerp between them how would I go about that?

Heres the results so far

268636-splineerror2.gif

Thanks again.

Ok so instead of using find rotation/location closest to spline point I instead opted to use get rotation/location along spline point. I then got the input key down time for W and S to add/subtract an alpha for the lerp which simulated movement along the spline that I was able to control.

Heres the results so far.

268652-splineprogresss.gif

some problems now are.

1.I added an offset on the Z axis on the get location at distance along spline but once it reaches 90 it centers the character on the spline as seen in the gif.

2.I still need a way to rotate freely while rotating along this spline since it needs to simulate movement left to right as well.

Thanks for the help so far guys I feel like im getting really close to making this work.

Since the weird rotation issue was the box collider, and not the spline rotation, it is not the issue that I was thinking. But just so that you are aware of it here is a post about the spline twisting that can happen. Spline mesh and loops

This typically happens when you go past 90. Depending on what you need, you may not have to worry about that. In some situations changing the up vector can be a work around, but yes, then you would need to correct the rotation you are setting by adding or subtracting 90 from whatever axis. Lerping between spline points was just an idea of a way to smoothly transition from one rotation to the next and avoid the flipping. eg: get rotation at spline point instead of at point closest to world location.

Don’t really want to steer you in the wrong direction, maybe you could provide a little more information on what the final desired behavior is. Is this a quarter pipe and your making a skating or bmx game? will the character ever go past 90? will the wall ever curve? will there be several of these and need to be able to face any direction? Do you need to transition from one to another?

I do appreciate your creativity in trying to come up with a new solution to this, but maybe one of these other solutions might work for you. I have seen other people do similar things with align to surface and completely change gravity.

Tilting character to surface

Dynamic gravity for characters

In fact, just today I saw this on the marketplace: Directional & Planet Gravity

Hope that helps!

thats lookin pretty good, as for 1. maybe get up vector at distance along spline * capsule half height and add that to location at distance along spline instead of a set z amount.
2. I think I need to think on that one…

The end result would be halfpipes/quarterpipes for a rollerskating game so there will be multiple of them. I did stumble upon those threads etc you posted before but I never got them to work

I tweaked the positioning of the splines as well as implemented your solution and it worked perfectly, I also added a bool so it wouldnt switch to jumping in the anim bp.

268671-progress3.gif