What to replace with timeline component to get the character going both ways in a spline, and distance and speed based instead time?

I am quite a rookie, just downloaded an example project from this platform to understand ssplines better. In this one its time based, even for me it’s pretty simple but unusable for me because I need the system to be simply distance based not time. The character will move along the spline towards or backwards depending on if the player is pressing on A or D key. How can I modify this simple BP to serve this objective, and primarily what should I replace the Timeline component with?

1 Like

This is not time based, its based on the length of the spline, because I think that timeline values goes from 0-1?

Plug your A trigger into Play, and the B into Reverse :slight_smile:

1 Like

I see but the character must move with a certain speed, like lets say 200 units. And there will be a lot of different spline sets in the map, and in much variable lenghts. The character must maintain the same speed everywhere. How can I set a certain speed?

1 Like

You need to set the timeline speed based on the length of the spline. The longer the spline, the slower it plays. So, some sort of division. If the spline is 2X as long, the TL should play at 1/2X speed.

If you drag the timeline reference from the components section ( bottom left ), you can drag from that and find ‘set playback speed’ ( or something like that ).

1 Like

I understand the logic but I don’t know how to do that. Like let’s say it will take 1 seconds to go 1m along the spline, how exacly can I implement this in blueprint in a universal way so I can use it everywhere in the map?

Lets say you’re happy with the normal TL speed on a 1M spline.

Then, if the length is 2M, you will need to set the TL speed to 1/2 ( 1 over 2 ). If the length is 7M, the TL speed will be 1/7th…

1 Like

Oh yes, and sorry for my rokieness but which actors and nodes I should use in this BP to achieve that?

1 Like

Like I say, if you rummage around in the components section ( bottom left ) you can find a reference to the TL. Put that in the graph, drag off it, and find ‘set play rate’. You also have the GetSplineLength node.

1 Like

So I should have to set it in every spline set manually? Is there way to figure it out matematicly in the bp? Like take the lenght, take the time for 1m, do the math and set the total time do travel along all the spline?

1 Like

No, the speed is based on the length, you can calculate it in the BP

1 Like

See this

1 Like

This is kinda unrelevant but, this A and B keys are not working, is it because I didn’t set the pawn as a main pawn or something? I am very new to both game making and UE sorry about that.

1 Like

I don’t understand. When I don’t set the gamemode it is moving by itself, with event begin play node, but when I set the gamemode it’s not moving.

You just need to enable input

1 Like

When I press play, the character is just spawning where I last leave the camera when editting. How can I get it spawned as attached to the spline? Also none of inputs are working.

This button decides what happens when you press the play button

Did you choose ‘current camera location’?

I don’t know anything about your setup, so why the player is not attached to the spline could have almost any reason :slight_smile:

1 Like

Default player start is not available. When I don’t set the gamemode its working with event begin play (only moves forward) but not working at all when I set the game mode and try to play it as the character. What sould I to to get it spawned as attached to the spline?

This is all the scene.

And this is the character’ s components:

1 Like

The game mode doesn’t know anything about splines, it can only spawn at the player start.

You would need to code your player to find the spline and use it.

1 Like

And how exacly can I do that?

By the way thanks for your help so far :slight_smile:

1 Like