Bringing a player pawn back to its previous position after hitting the killzone

I’m fairly new to the Unreal Engine, and I’m currently creating a mini golf game.

So far, the only real problem I’ve come across is creating a position reset in between strokes, so that if the ball goes into out of bounds it would go back to its position before shooting, instead of how I have it currently set up (using the killzone to reload the entire level).

I’ve tried creating an empty actor and getting it to move to the player pawn’s position whenever the ball wasn’t moving, so that I could save the position, but I couldn’t get that to work unfortunately.

I’m assuming the solution is pretty simple, but I can’t wrap my head around it for the life of me.
If anyone’s willing to help, it’d be much appreciated :slight_smile:

hmmm i would think to have a series of volumes that represent the bounds of the green. then when the players ball overlaps the bounds actor you get the location, get forward vector, then calculate X number of units backward and save this new location as a variable. then when the ball is done moving you set the location to the variable you set previously.

Save the location of the ball when you swing. reset to it when you go out of bounds. You can probably set this wherever you apply the swing force to your ball.

ThompsonsN13’s solution will also work but it will reset the ball back onto the green from where it fell off not where you took the swing.

What node would you use to reset to it? I’ve tried something like this by spawning a plane wherever I take a swing and using a move component to node to move the ball back to the plane’s location, but it wasn’t working…

I think my problem lies in how to reset the location of the ball to the location variable, I’m not sure how to do that with a player pawn. Thank you for your answer though :slight_smile:

to set the location you literally use a set actor location node, its about as easy as it gets.

of course you would want to wait until the ball is stopped before setting its location. also this is for if you want the ball to be placed where it went out of bounds not to return it to its original location.

heres the basic setup if you wanted the ball to return the location where it was hit from. i did this in the level bp but you could easily do it in individual actors.

basically when you hit the ball you record its initial location in a variable, then when the ball goes out of bounds (i used a overlap volume) you just set the balls location. you would probably record the location in the ball bp in which case you would just need to drag off the cast return pin in search for the variable needed.

Hey, thanks so much for your answer! The only tiny hiccup I’m seeing at the moment is that I’m trying to do all of this into my ball blueprint, but I can’t call an onActorBeginOverlap for my trigger box in side of there.
But, if I call it inside of the level blueprint, the Start Location doesn’t have a target and fails to compile, and I don’t know what to assign to it (see screenshot for what I mean)

The first part works, as my print string is giving me world location of the ball.
Thanks so much for your help, guys.

If you are setting your variable for the start location in the ball bp then all you need to do is get that value from the ball actor. So drag off the as golf ball pin and connect it to the target on the get variable node ball location.

I already tried that, but it doesn’t work. A print shows me that it is going through, but the location of the ball isn’t actually changed. Would it be because it is a player pawn? I’m not really sure what’s going on.

A print shows me that it is going through

shows what exactly?

if you have the reference right and its running through the cast without issue then the issue must lie where you are setting the location. this is of course assuming that you are getting the variable from the golf ball bp via the as golf ball pin.

I fixed it! The problem was that my golf ball wasn’t the actual scene root. As soon as I put it there, the location reset worked as expected. Thank you very much for your help!!