Download

Spawn player with or without weapons depending on game mode.

Hi Everyone,
Cant find any other posts about this so im going to ask here.
I have a FPS Multiplayer template with about 8 different game modes. At the moment the player spawns with primary and secondary weapons automatically. However i would like to spawn players without weapons if a particular game mode is selected. As im a noob im not sure how to add this into my current blueprints or where exactly i would put it. But logically in my understanding i have a few options.

  • Destroy weapons on spawn if in the selected game mode.
  • Say If game mode A is selected, set default weapons to an empty weapon child blueprint.
  • Or set default weapons to none, and if game mode A is selected then open a new widget without the option to choose weapons instead of the original widget.

Any help with this would be much appreciated. Ive looked in both BPbasecharacter and basecharacterPC and tried a few things but im just not sure what nodes etc to use. Also if anyone knows of any tutorials on this subject please let me know, or any other easier method would be much appreciated.
Cheers.

ON BeginPlay() just add the weapons if they are not added? just override where the weapons get spawned, and do a gameinfo check… I hope it helps.

Hi, thanks for your reply. So in this case the weapons are added by default. I should add that my game is all in blueprints. So just trying to figure out the easiest way to setup a knife only game mode. Thanks

I’d setup a switch or branch on the Begin play and spawn the weapons as needed.

e.g.
Branch method … If (game mode == “this”) → spawn, else don’t
Switch method … Switch on Name … each mode has a name that you can get from gamestate. Pipe name to the switch.

OR

Have your game mode fire an event on the player class to spawn them.

So what your saying is inside the individual Game Mode Blueprint e.g FPS_DM_GM (deathmatch game mode), i can run a custom event to spawn players either with or without weapons? If that works then will i need to remove the equip weapon logic in the main parent base character so it doesnt overide the individual game mode events? hope that makes sense lol, and thanks heaps by the way, when i get passed this hurdle its a big part of my game logic.

Not on my computer, but post to follow this thread later and perhaps bringing some answers because the goal of the next steps in my project is the same!

Yes.

Create a Function in the gamemode that will spawn and attach the weapons to the player … after the gamemode “creates players → spawns character → possesses”.

Or You can have the Function written/reside in the player class. Create an event and pipe the event to the function.
When the game mode creates the player -> spawns character -> possess -> Call Event.

So heres by blueprint for equipping primary and sec weapons when spawned into map. Id like to add a branch or switch method to ask if game mode is “gamemodeA”, then set default weapons to none. otherwise equip default weapons. And there will be no doubt other game modes that ill create that will start without weapons too so will be good if i can add a node where i can put multiple game modes as the condition?? thanks again

So in your character class Create a custom event… for my example we’ll call it “ServerSpawnWeapons”.

Add an input variable of String type to the event… name it “gamemode”.

customevent_input.jpg

Next, Out of the Event execute pin add a “Switch on String” node. Pipe the “gamemode” pin to the switch “selection” pin.

Next, create your case statements.

e.g.

From here all you have to do is have the server call this event for each player.

There’s many approaches for this. It just depends on your particular setup which will be the better option.

My game modes create the controllers and spawn the actor classes, then attach (possess) the controller to the character. For this type of setup you’d simply call the event after the controller takes possession of the character.

e.g.

A more simplistic “getting started” approach would be to simply get all actors of class -> foreach loop -> call event.

I highly recommend adding/prepending a delay or using “Set Timer by Function” for this approach. You want all characters spawned, before trying to attach weapons.

If the Game mode does not need to spawn weapons then don’t call the event.

Holy wow thanks for that ill give that a crack when i get a chance and let ya know how i get on. Very much appreciated!

So ive tried to put this into my blueprint, shown in image but im confused as to where this gets what weapon to spawn as my spawn weapon logic is called in the base characterPC, not inside the specific game modes. does that make sense? lol

Server Spawn Weapons is not replicated. It’s just a plain old event in the character class. Yours is setup to run on server. Look at the first image I posted.

In the game mode you call the characters event.

Here’s a video walkthrough.

[quote=“Rev0verDrive, post:12, topic:140616”]

Here’s a video walkthrough.
https://youtube.com/watch?v=P4_jt9iwjgk[/QUOTE]

Awsome thats such a good help and will give this a go when i can, but just one question, how does the game mode ref pickup the game mode? e.g in the server spawn weapon call the text says TDM, But should i be copying in the pathname for team deathmatch instead e.g /Game/FPS/Levels/TeamDeathmatch. Is that right?

For each game mode you have in your project you should have a dedicated game mode class.

e.g. DeathMatch -> GM_DeathMatch, TeamDeathMatch -> GM_TeamDeathMatch.

I strongly recommend reading up on Game Modes, and Game States if there’s any confusion with this.

So there’s no reason to have any dynamics in referencing game mode etc. If you’re working with the TDM game mode then type TDM in the string field. Otherwise you can create a string variable in ever game mode BP and set its value. Then use that variable with event node.

e.g. GameMode (string) … value: TDM etc.

This is an absolute waste of resources FYI considering you’re scripting the event in the “actual game mode”.

Thus: I’m editing the TDM mode, so the string value for this node should be TDM…type TDM.

Hello,
Have you evolved on the problem and find a logical way?
At first, you want to hide weapon in Multi or Only In Single Player (Archviz for example)?

It’s seams you can’t use multiples gamemode on only one Level…

The logic process is extremely trivial. Everything you need has already been posted. How complex this is for your setup is dependent on “your setup”.

Do you have a game mode?
Does the game mode require weapons at spawn?
If so, create an event in your character class that spawns the required weapons. Have your game mode call said event when the player has been spawned (documented on previous page).

Thanks for help and lot of informations Rev0verDrive.
I’ve watch the video and read everything, but… :slight_smile: Yes, I don’t like “but” me too! :wink:
The inital statement is “I have a FPS Multiplayer template”, in this case the easiest way, on my mind only, is to modify the “On possessed” function in the “BP base character” and to switch on actual game mode before calling the event “Server Equip Weapon” and avoid it for a gamemode without weapon.

Of course, your answer is very good! because you can adapt weapons to specific game mode with more flexibility.

Hey guys, sorry havent been on here for a while, but i did find another way and because the FPS multiplayer template i have is so complex, i searched through the blueprints and found a function ‘On Possesed’. Then i just used a branch to check which game mode is in play, and set with or without weapons from there, which worked great. And yes i have about 8 different game modes to choose from and can use any one of them in one map. So thanks heaps for your guys time.