Hello, everyone.
I followed this tutorial (Unreal Engine - Spline Path Animation Tutorial - YouTube) to have an actor (in a soldier appearance) follow a spline path. However, although he is walking along the path, he faces towards the wrong direction. He is now walking side-way along the path rather than facing forward. I tried changing the hierarchy structure, rotating the actor, rotating the spline path itself but nothing has worked so far. Any idea what might be happening and how to correct it?
Notes: the coordinate space is set to “World” on both functions “Get location at distance along spine” and “Get rotation at distance along spline.” Changing the coordinate space to “Local” didn’t fix the problem.
I appreciate your response.
Thank you.
show us your script so we can see what youve done. the simplest answer would be to add a offset to the rotation but there mey be a better solution if we see what youve done.
Is “Main Player” the top of your actor hierarchy? Possibly it is rotating something else in the actor and not the actual mesh? I can’t see from you current screen shots.
Hi,
The “Main Player” is not on top of the hierarchy. The “Scene” component is the current root. When I try to simulate the game with the “Main Player” as the root, everything goes out of whack. Let me upload a screenshot of my current hierarchy.
I see what is going on. It was odd to me that you had the “spline” component as part of the actor you are trying to move.I recommend keeping them separate. But in any case, if you look closely at the tutorial you linked to, the hierarchy is “spline” no children, and “cube” no children. So they are completely separate components when you rotate. You are rotating a child component but not the parent and I think that is causing some issues. Try dragging “Main Player” and dropping it on top of the “spline” component. This should then remove it from the spline hierarchy similar to how your “billboard” component is not a child of your “spline” as you can see by the indentation.
Hmm, it doesn’t appear you have although I’ve never set up a spline like that before. Try maybe instead of the “transform” node set world location and rotation separately. It shouldn’t make a difference but sometimes the game engine is weird like that.
Thanks for replying. That actually was my initial setup. It didn’t work so I tried rearranging the hierarchy into what I have currently to see if it would fix the problem but it hasn’t. I’m not sure if I’m making any newbie mistake in the settings over in the details window.
i think your rotation is off by 90 degrees for the skeletal mesh. if you select the mesh and it shows the location gizmo which way is the red arrow pointing? if its not facing the characters forward direction then thats the issue. this is easily remedied by either adding an offset to the rotation in your script or by adding a scene component then making the mesh a child (of the scene component just created) and rotating the mesh in relation to its parent. then you would move the parent instead of the mesh.
though this wouldnt solve the issue of your other question thread. to solve all the issues at once i would abandon the idea of having everything all in one blueprint. i did some testing and im not sure components in the same actor can overlap so i would either spawn the skeletal mesh at runtime or use one thats placed in the level. in the picture below you will see an example script that uses a mesh placed in the level. the basic idea is that we will get a reference to the skeltal mesh actor via a public variable which will need to be set when you place the spline bp in the scene. so create a variable (i called it character mesh), make its type skeletal mesh actor object reference, and make it public by clicking the little eye next to the variable name in the bottom left section. then setup the script as shown in the picture by replacing the set world transform node with a set actor location and rotation node and the variable. also just prior to the setting of the rotation i used a combine rotator to offset the rotation to compensate for the mesh rotation being off by 90. you will also need to adjust your overlap event on the box collision to check for the different actor (i showed this as well resulting in a print string).
I would recommend a set-up where the spline and the character you want to move are not part of the same blueprint. The set-up I have created below will allow you to put in as many splines as you want and move as many actors as you want. It is more versatile than the tutorial you watched which only allows you to move 1 specific actor and might make it easier to troubleshoot rotation issues. Here is the set-up. The insides of the timeline work a bit different because instead of setting a hard and fast “length” and a float track to make the distance go 0-100% of the total spline length, I created a variable to keep track of the total distance. There is another variable I created and made public (check the little eye next to the variable) called “speed” (set it to like 500+) this allows you to change how fast the player or object moves along the spline path from the editor without having to enter the BP itself. My timeline loops, but in your case I wouldn’t have it loop, I would change either the speed or length of the timeline in seconds to suit your needs for when you want the player to stop. The “actor to move” variable is created by clicking on the variable “+” on the left hand details panel and searching for actor object reference. The second image shows you how to set the “actor to move” variable from the editor. Select the spline track and on the right side details panel you will see the public variable “actor to move” you can then choose any actor in your level to feed in.
Thank you both ThompsonN13 and Nebula Games Inc for the instructions.
No problem. I’m assuming you managed to figure it out then?
Sorry for the delay in response.
Yes, partially. I decided to rest this case for now and focus on my cinematic with sequencers first since there’s a tighter deadline for that. Of course, I have tons of questions regarding that topic as well. I will be posting them shortly.
Again, thank you so much for your time and guidance.
Fair enough. Well ask away, we are all here to help you meet your deadlines haha