Make object follow a path?

How can i make an object in my level follow a desired path? A path like helix and spiral or manually curved one?

If you want to make them follow a path you define your self I would check out the spline component. You could define the path with a spline and use the normal navigation system to make them move between points on the spline.

To do this you would need an actor blueprint with a spline component. Then make some sort of function that returns the next point on the spline. You could control how smoothly they follow the spline by sampling it at different intervals. Eg every 10cm for a smooth sample or very 100cm for not so smooth but better performing.

The function you’ll need from the spline component to make this work is GetWorldLocactionAtDistanceOnSpline. Your function to get the next point just needs to return the result of this with something like PointNumber * SampleLength as the input.

Thanks for your answer… i tried but somehow i’m not able to edit spline inside blueprint. i checked and found its a bug that i cant edit spline inside blueprint. which was reported in 4.7.4 and apparently not resolved yet.

what should i do now? any other way ?

Generally you would put the actor into the world and edit the spline in the world. I’ve never tried to edit one in the blueprint directly.

You could still set the points and tangents in the construction script manually by calling appropriate functions on the spline component.

You could just make an actor that holds an array of points for the guard to follow but it will be much harder to achieve things like helixes and spirals.

I think 2nd option is something that i can work with now… Thank alot for shwoig me a workaround :slight_smile:

i’ll try making my helix using construction script. once its done i think i can manage to get the point and location of next point. but which node should i use to move my component/object to the next point?

and also can you clear few things out? like will there be smooth turns after reaching point 1 and heading toward point 2? and will it follow the path or just the points? if my object going to follow path then turns should be smooth i think! thanks!

also if you can show me a blueprint of “object using some spline points” to move that will be much easier for me to understand!

In the long run you’ll probably want to look into behaviour trees. There’s a few good tutorials around the web and on youtube.

In the short term for testing you can use the ‘AI move to’ node in Blueprint to tell an AI to move to a particular location.

The navigation component will make the AI follow a path that’s direct as possible to the next point so how smooth it will be will depend on how many points you use. Your only approximating a curve really. If you really want it to be smooth you should switch to using splines as soon as the bug is fixed.

My object is going to be flying in the air in order to follow path. will navigation component be able to follow path in air?

No, but if you don’t anticipate there will be any obstacles then you can just use normal movement instead.

there most likely not going to be any obstacles but it has to follow a helix path in order to get in air! what should i do then?

also take a look at this video this is the kind of result i’m trying to achieve!

Yeah so this is clearly using a spline. I don’t think them not being editable in the blueprint viewport should be an issue. Just edit in the level.

How I imagine this would be working is in on tick you would update the position and rotation by calling GetWorldLocactionAndTangentAtDistanceOnSpline or some simlarly longly named function with deltatime * speed + lastposition.

Okay thanks, i got it worked my object is moving. only problem is its moving more then it should like spline is scaled 100 times. but i think this is the issue because i edited the spline using construction script in blueprint. but its moving so i think i can call it solved. i’ll figure out the remaining problem. Thanks again for helping!

Cheers :slight_smile: