Yes sir I’m still around. I have a weird work schedule today, now until around 2 and then again at 5, but feel free to ask and I’ll get back ASAP!
So i need a little bit of help with something I am trying to do but dont really know alot about storing variable data. I am using Generic Shooter that Alar made and I am trying to implement a turret system.
- Game starts
- Player is given default weapons
- Possess a turret
- Get out of turret with ammo and health from before getting into the vehicle.
The possess turret blueprint destroys character actor when getting in and then respawns a new character
But the issue i am having is this, I have health going back to the new character fine because health variable is on the character so i can send the health values to the turret easily enough to store the health values and then give them back to me once my player is re-spawned.
But I cannot figure out how to store the ammo variables from the guns my character had onto the turret and give the ammo value back to the spawned default weapons.
Any help would be very appreciated.
It sounds like an easy fix on the surface. I think that instead of transferring these variables between the character and the turret you should store them in either the game mode or the game instance and then you can feed them back into where ever you want. The game instance can store variables that aren’t destroyed until the game is completely closed out of. The game mode is good for each level as it stores all important information to the game mode or type that you are playing. By default you won’t have a game instance that you can get to in blueprints so you can make a new one from the create blueprints menu and then set it in the game mode I believe.
As far as your weapons spawning; how come you are keeping ammo variables on the weapons themselves and not in the character or game mode or game instance? Just curious and trying to get a feel for your structure
Also just so I’m on the same page, you want the player to be created after leaving the current with default weapons but retain the amount of ammo they had when they entered the turret, right??
That is correct .
And I am not very good at this kind of stuff. How would I go about storing data on a gamemode or character but still make the weapons use the ammo from them? I have been trying to learn how to use structures and enums and arrays but I am failing so bad xD
I’ve posted above the 2 answers. So this chat doesnt get any smaller
I can make a sample project showing how to do it. What version of unreal are you using?
I made a sample project. All of the things that i created for it are in the Content folder. The only other things that I edited were the FirstPersonCharacter and FirstPersonGameMode blueprints located in the default firstpersonBP folder. There are many examples of referencing the gamemode blueprint in there. And no need to keep resetting variables every time you enter the turret! I’ve set up a turret for you to possess, some ammo to pickup, a system that checks your ammo count when you try to shoot, and an object that hurts you so you can see that it retains health as well when the player is re-spawned.
The attached project is linked below Using Unreal 4.18.2
If you have questions feel free to ask!