Need help possessing and unpossessing vehicles while keeping weapon info

[SPOILER]Things i am using:

  • UE4.11.2
  • Generic Shooter (BP_PlayerCharacter, BP_BaseWeapon)
  • My own scripted turret (TurretTeam0, TurretTeam1)

OK, so lets give you the scenario.

  1. Game starts and player is spawned with default weapons. (Rifle, handgun)
  2. Walk up to turret and press E to enter turret. (That is working fine. I can fire the turret projectiles with no problems)
  3. Press E again to exit turret. (Here is the hard part for me. When i press E to exit, it spawns and possesses a new character BUT, also new default weapons) (I can remove the function to give default weapons to the character on spawn but then my character has no weapons)

So i placed some weapon spawn pods inside the map so I can at least have a weapon. But when I pick up the weapon, go into the turret and leave the turret, i no longer have that weapon i picked up.

Rundown:

I can possess the turret and get out of the turret easily. But the problem is, when exiting the turret, the game does not keep what weapon I had on the character because the character gets destroyed when possessing the turret and then recreated when exiting the turret.

My question to you guys:

How do I make the vehicle or character remember what weapons I had on when entering the vehicle and then give them back to me when i exit the vehicle with all the ammo correctly remembered. (For example. I have 120 ammo when picking up weapon. I fire weapon 2 times to then give me 118 ammo. I enter turret and exit turret and I then have 118 ammo again.)

My theory:

When possessing the turret, place the current weapon on me into an array along with its ammo and then when exiting the turret using the info inside the array give it to the newly spawned character.

My blueprint issues:

I am not very good at using arrays and dont know where to place the array code. (Inside the turret?? Inside the BP_BaseWeapon?? Inside the BP_PlayerCharacter??)

Can anyone shed some light on this please. I really need some help. Been trying to figure it out for 3 days now, with searching google for answers and reading forums but i cant seem to find anything that would help me out.[/SPOILER]

The SPOILER above is all fixed but I now have just 1 more issue. I have made the blueprints now so that my character is attached to a vehicle and then controls the vehicle. BUT when I exit the vehicle with the DetachActorFromActor node, and then use the SetActorLocation, with GetActorLocation + GetActorRightVector X -100 Int…the SetActorLocation spits my character out of the vehicle at the location of where i got into the vehicle in the first place.

How do i make my character move with the vehicle (Character is hidden but a mesh is visible inside the vehicle) and then set location of my character next to the vehicle?

Hi ,

Thanks for the reply. When you get off the vehicle, does your character end up back where you originally got on the vehicle or does it get off at the location of the vehicle? That is my only issue I am having now :slight_smile: I can get in and out of vehicles without losing my weapons.

BUT you did raise a good point also about multiplayer. When i run 2 game windows (1 server window, 1 client window) the client window cannot get into the vehicle using the Input button i set :frowning: