This topic was probably discussed many timed before, however I still cannot find the answer.
Basically, all I want is to move an actor along a spline, while changing its direction at turns. I know there’s an example of this in ContentExamples, but in it the object is simply made to move slower on turns, what I need is for it to rotate (follow spline), not slow down. The best example of this is a car.
Please help, it seems like the most basic thing, but I just can’t get it to work. In 3dmax it takes like three clicks, but in Unreal it’s kind of a nightmare
Would appreciate any help!
You should just be able to get the spline tangent vector and then “make rot from X” on that. If that gives you sideways rotation issues (it probably will), then also get the spline Normal and use that as the Z and the tangent as X and use “Make rot from XZ” or something. May need to tweak the rotator depending on your assets forward direction.
Once you have your rotator value you just use “set world rotation” on your actor. Make sure you sample the spline vectors at the same point as the object position along the spline.
Thanks for your reply, it seems I’m one step closer after it. So, I got the Get spline tangent part working, and the actor does follow the spline just fine. But as you predicted, the sideways rotation is present. What I cannot figure out from your reply is where to find “spline Normal”? Cannot find that node, context sensitive or not
Here’s my setup as it is right now:
Could you please elaborate a bit more on how to fix that.
It looks like it is called the “Spline Up Vector”. “Right Vector” is probably the binormal.
Also note that in some cases you might opt to simply use a fixed 0,0,1 as the Z, or use some game logic such as results of hit normal on line trace averaged over time if you wanted some kind of simple response to the level geometry.
Hmm, no spline up vector. There’s GetSplineUpDir, but its target is spline mesh component, not spline. All that I need is to rotate that mesh 90 degrees to make sure it doesn’t move sideways. Is there any simpler way to do that? (obviously I tried rotating the component itself, but it doesn’t help at all)?
I think this is what’cha want right here! https://www.youtube.com/watch?v=bJXG8y31bVk This is what got me started and I’m making spline paths perfectly now!
Maybe this has since been added in 4.8 or newner… but I see the spline component up vector node like this:
(also has the distance version like yours above)
But as before if you just want to force the vehicle to be upwards you can specify 0,0,1 as the Z vector when “making rot from XZ”… sometimes you need to play with those depending on the orientation of your model.
Dude, thanks a lot! That’s precisely what I’ve been looking for, simple yet incredibly useful.
I am using 4.8. Probably I’m doing something wrong or looking in the wrong place. The problem was not upward direction, it’s just sideways (so maybe I’ll try the same solution but with Y). Anyway, as for now, it seems that I’ve got a solution with the link that SuperSonic68 has provided. Maybe ContentExamples can be updated to include this in the future, as I think many others may need this. Thanks for your help!
If you just do Make Rot from Y instead it should fix the sideways problem. Your mesh is probably facing the Y axis.