Download

How to move an object along a spline ONLY on XY coords

Hello everyone! I am trying make my character move along the spline. I am building a 2.5D game and the player will have obstacles to pass. I thought a good approach of this would be to have the spline drawn on the XY plane (so, no depth on the Z axis) and have the character follow along the spline only on the X and Y coordinates.

HighresScreenshot00001.png

I managed to make the player follow along the spline, but I don’t know how to make it stay on the ground (or freely jump or whatever).

d01b52a934bdf0c53b80051941af2084982ac24a.png

How should I get the Z for this?

You’re on the right track with the second screen shot. For the Z, you’d get the actor location and plug its Z axis in. The only problem is that would assume that the ground is perfectly constant and doesn’t change height at all. For a ground that changes in height, you’d have to do a line trace down from the spline or something, to get the Z axis value.

I found somewhere that this would not be a good practice as it would prevent Unreal from simulating physics. What do you think?

Since you’re arbitrarily moving it on a spline already, I think you do not care about physic.

I think you’ve already guessed I am a beginner. Could you please explain (or link me to something explaining) what physics Unreal does for me, by default?

Simulating physic let the engine handles the movement of an object, depending on its mass and the gravity of your world.

But I think you don’t want your actor to be subject to physic, else it wouldn’t travel along the spline.

Since you don’t care about physic here, you can set its Z value like you had in mind I believe.

Hello again!
I have the following system for moving my player. I thought it would help me move the player on the spline I was talking about in this thread. So I have the player spline right here (the green one):
capture1.PNG

Here is the blueprint for moving the player:

a39ff54f7d18b8a53e016fb03ebaa471ae7bd4bc.png

Unfortunately, I don’t think I can calibrate the torque so the player will stay on the spline, I think this is impossible. Could you give me some hints, please?