How do you save player location on 'button press' and respawn them there?

Hello All,

I am working on a golf project and have hit a wall. I have an ‘out of bounds’ area marked and after three seconds, the player respawns. That is built and working.

The functionality I can’t seem to figure out is marking the last place a shot was taken. I don’t want the player to go back to the main starting spawn. Instead, I want them to teleport back to the last “good location”.

image
I have the Shoot action set to the Space Bar. My thought is, when the button is pressed, mark that spot as a transform and set that variable.

image
Then once the timer is reached for being out, a function is called and respawning the player is the last step. I have the spawn transform set to the location that should be pulling on "Space Bar Pressed’ but so far it’s only going back to the main spawn.

Thanks in advance for any assistance. I hope i was clear enough. If not, please let me know.

1 Like

What’s in ‘respawn player’?

My apologies, I should have included that.

image
it’s a pretty basic system. Spawns the actor and uses the Posses function to ‘attach’ the controller. This also works. I am able to fire again after respawn.

I’ve also been printing the ball location to screen and I can’t get it to update in real time. Something I am doing is not correct. I’m getting coordinates, but they are the same no matter where the ball is.

Thanks in advance.

I can’t see anything strange with that.

My thinking is something else is going on which I can’t see here.

Just to check, you’re not using ‘open level’ or ‘reset level’ or ‘reset player’ anywhere?

As an aside, I think you’ll find you’re leaving players all over the place. Because you’re not removing the old one each time :slight_smile:

What sort of actor is the ball? Is it just a mesh, or a mesh in a blueprint?

Thanks again for the reply.

I am not using any of those level events. I have things on BeginPlay, but that just sets a variable for Par amount.

I do have an AnyDamage event in my pawn blueprint that destroys the actor and sends it to the ‘last shot location’ (in theory). That’s triggered by the bounds area. After three seconds, the player is his with damage, thus triggering the AnyDamage event. I tried to account for the extra actors already, but I do TRULY appreciate the insight.


(This is the rest of the event from the screenshot above. It’s ugly as I’m mid-test, my apologies.)

The actor is a custom blueprint. The three components are a sphere, a spring arm, and a camera. Ball rolls, cameras sticks to it.

As the newest update: I was able to get it working. I could not get the transform to update on the pawn, regardless of location. I tried tracking the sphere component directly and got progress.

I now have the ball spawning at it’s last good location BUT the ball is microscopic and the rotated is EFFED.

I’m not sure if I’m onto something or I am chasing the wrong stick. Either way, this is where I am at. Thanks again for all of your help.

What are you trying to destroy here?

Because at the moment, it will destroy itself, which means the red part won’t run ( or not reliably ), because the actor no longer exists.

PS: You don’t need to respawn the ball and player anyway. You can just wait a few seconds, and then just move them back to the last good location.

I am using that event to destroy the original actor/pawn. I have a UI widget that informs them they are out of bounds. That stays on screen permanently if I don’t destroy the original actor. The printed coordinates also show double values. This was the reasoning behind making it go away. As of yet, I have not had issues with the respawn player event not working. That being said, if there’s a better way to do it, I’m happy to try.

As far as not respawning the player, would you just suggest using “Set Actor World Location” after the delay and use the ‘Last Shot Location’ transform variable?

I apologize for my inexperience, I just kind of jumped in and started. I’d be lying if I said I have a real handle on any of. The logic part is easy to me, it’s the creating of the flow that eludes me.

Again, I appreciate all of your time and guidance.

After thinking about the logic path, I see what you mean. The Destroy Actor becomes irrelevant , as I’m simply transporting the player form A to B.

Now I just need to figure out the right functions to call. Wish me luck.

Yes, exactly :slight_smile:

IT WORKS!!!

I have the out of bounds area running a delay and then spawning the player at the last good location. I am having a problem with forward rolling after the teleport back. the player move carries over the velocity and the ball remains rolling. The lazy answer is to increase the delay amount and allow time for the ball to stop. It seems like a more reliable solution to find out how to stop the momentum once it’s moved.

I’m sorry to lean on you for something I’m sure is simple, but would you mind point me in the right direction? Thanks in advance.

*I will mark your answer as correct. I just don’t want to lose the commenting ability on this post yet. I will make sure you get your deserved credit though.

1 Like

Great :slight_smile:

I can’t quite tell how your system is working at the moment, but things that might be useful:

  1. You can know if the ball is still travelling with

image

( got that = node with )

image

  1. So, it’s up to you. You can wait until the ball stops moving and the reposition. Or you can immediately reposition and just stop the ball

image

( I’m guessing ). Or perhaps

image

and then turn it on again, after moving it.

  1. As for catching the out-of-bounds stuff, you could have collision volumes around the course. When they get triggered, the just send a message to the ball and player. Or, you could have a collision volume around the course, and when the ball stops moving, it checks if it’s still inside it.

And so on… :slight_smile:

Thank you again.

It’s working as I wanted. The ball teleports back and then it’s velocity is stopped. It’s exactly how it should be. Thanks again.

1 Like

Excellent :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.