Game Instance?

You’re nearly there, but like I say, you need to do something on begin play in the character. You don’t have that at the moment.

I notice when you do an actual pickup, you set the equipped mesh. That’s what you need to do on begin play in the character.

At the moment ( because we did a very basic example ), you are only storing a bool in the GI, if you want to run your pickup code, obviously you need to store the mesh that was picked up in the GI. Otherwise, how are you going to know what is was?

So, when you pickup, store the mesh in the GI. You don’t need the bool now, because we have the mesh instead.

Then on begin play in the character, check the GI and see if the mesh was set. If it was, set the equipped mesh to that. Because that’s how your pickup works.

Is it making sense? :slight_smile:

Thanks for the tips. Would it work if I move the pick up code in my player Blueprint to the begin play event?

I think you’re missing the point. I totally understand, because changing levels is a little weird, when you’re not used to it.

The problem is, when you use ‘open level’, everything gets thrown away, including your player.

It looks like your player just goes to the next level, but it’s actually a totally fresh player. That’s why you’re losing the pickup.

So, we have to remember what mesh we picked up in the game instance before we change levels. No problem. But we still get a new player in the new level, so we need to find out what the mesh was, and put it in the player hand ( or wherever ) again. Best place to do that is begin play.

I will do an example ( gimme a while… )

Thanks sorry about this. It’s the first time I’m using game instances, but obviously it’s one of those thats needed.

So in my GI

image

And in my player, the code starts just the same as yours, but now it says

Notice we can’t call ‘pickup’ on the actor until we’re totally done, because we can’t have it destroying while we’re in the middle of saving the mesh.

Then, like I say, on begin play, we retrieve the mesh

It looks like this

levels

1 Like

Thanks for this, I will implement this into my player blueprint and let you know if it works. Thanks so much for this. I’ve been looking everywhere for a detailed tutorial with this.

1 Like

It Worked. Thanks so much for this detailed tutorial. As I have said before, I looked all over youtube and the internet for an in depth tutorial, but there weren’t any. Thank you so much again.

1 Like

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