Remove player from start or end of spline

I’d like to launch my character off of the spline based on the direction I mounted the spline on.

so if I entered from the start of the spline I’d like it to launch from the end and vice versa.

Any thoughts on how I would go about this?

Thanks!

the launching part is easy just get the location of the last point along the spline and if the players position if equal then launch character.

the second part is a bit more difficult but i imagine you could just set a variable that represents the starting point, say an int that 0 or 1, or a bool. then you would just need to use a switch or branch to change what script runs depending on the direction the character is moving.

below you will see an example of what i mean. the first picture shows the deciding which script to use based on the bool variable, this basically tells the script that you want the character to move either toward the endpoint or toward the start point. then comes a function which does the actual moving of the character (see picture two for the script). the last part of the script just compares the characters location to that of the end or start point and if its close then it launches the character.

do note that this is an incomplete setup and is an example to show the logic, you will need to develop a way to set the bool variable. the implementation will greatly depend on the circumstances of your game and how you want to implement things.

Hi thanks for the response, I’m already moving my character along the spline based on its velocity which drives it toward either end.

What I’m wondering now is how to get the start point or end point then do a branch check to see if it reached either?

I have it setup so it can enter the spline at any point and then move forward using the velocity it got on the spline with.

Here’s the blueprint thanks for the help!

Also I’m not really clear on what those two nodes are doing in relation to the spline points especially the error tolerance if you could explain that too that would be good thanks.

in the top picture pretty much everything to the right of the move along spline function is the check to see if the character is near a end of the spline. the top one is getting the location of the last point of the spline then comparing it to the characters location, the float value is acceptable deviation or basically it just says if the character is within 10 units of the target location thats close enough.

as for the particulars on checking when the character is at a end i did it on tick here to make it simple, but also added in a bool in case you wanted to specify the direction but you could just as easily check one location and if they werent there then check the other. so it would be compare character location to end point if true launch character if false check is player near start point. if you didnt want to use tick you could also use a collision volume that on begin overlap triggers an event. that would be pretty simple too, just place a volume at either end of the spline then on overlap component execute the launch script.

Thanks, I solved it by taking the vector from the find location closest to world location and plugging it in to the = vector instead of the actor location, I did use the collision volumes as a temp solution but I wanted something more compact.

Again thanks for the help!