x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Using Generic Shooter: How to implement a system that allows for specific characters depending on what team player is on?

Hi! I just recently bought generic shooter and am trying to customize it to my liking. Whether or not I use it to create a releasable game is not yet decided. With that said I am trying to implement a system for the team death-match game type. Currently when joining a match the player will enter a lobby, have the option to change teams and then when ready or out of time the player will spawn with the main character class with a set team color. What I would like to achieve instead is to have a menu option before each spawn, depending on the team the player is on, to give the player the option to choose a specific character, and then spawn. I will be able to give each character its' own set of weapons and stats, I just need help creating the choice of character. Any help is appreciated, I have little knowledge on c++ but I am c++ capable.

Product Version: UE 4.18
Tags:
more ▼

asked Dec 20 '17 at 11:01 PM in Blueprint Scripting

avatar image

HeadHunter625
21 1 2

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hey there, check this.

more ▼

answered Dec 20 '17 at 11:06 PM

avatar image

xlar8or
5.9k 156 127 302

avatar image HeadHunter625 Dec 20 '17 at 11:41 PM

So, I know I said that I am cpp capable, turns out I was wrong. Is their a chance that you could explain what is being done in blueprints? I am currently taking a course on cpp and ue4 so I wasn't lying, but it turns out I am unable to replicate that within this project.

I made a struct and a variable of it within the player controller being used, but I cannot seem to find a RestartPlayer Function inside the deathmatch gamemode class. Thanks for answering though, If i was better at c++ then the original answer would probably do the trick. Another issue is that all the classes within this project are blueprints, so I don't even know how to edit them with code.

avatar image xlar8or Dec 20 '17 at 11:57 PM

So the basic idea of the link that i've sent you is that in your custom game mode blueprint you should be able to override a function called GetDefaultPawnClassForController, which takes a player controller and based on that you can decide what is the character class that he's going to spawn for that player. In order to make that decision you need to have a custom player controller and add to it a variable that tells what character the player has selected in the menu (lets say for now you have classes like medic, engineer and soldier). When you override the GetDefaultPawnClassForController if you cast the player controller to your custom player controller you should be able to access what class the player has selected, based on that you can do something like:

 UClass* AYourGameMode::GetDefaultPawnClassForController(AController* InController)
 {
       AYourPlayerController * PlayerController = Cast<AYourPlayerController>(InController);
 
      // 0 for Medic
      // 1 for Engineer
      // 2 for Soldier
 
      int32 PickedClass = PlayerController->GetPickedClass();
      UClass * Class = DefaultPawnClass;
 
      if(PickedClass == 0)
            Class = AMedicCharacter::StaticClass();
      else if(PickedClass == 1)
            Class = AEngineerCharacter::StaticClass();    
      else if(PickedClass == 2)
            Class = ASoldierCharacter::StaticClass();
 
      return Class;
 }
avatar image HeadHunter625 Dec 21 '17 at 01:03 AM

Thanks for your help, but I messed something up that I'm unaware of then the auto save (I forgot to turn off) caught me off guard while trying to find it so I'll be creating a new project most likely. I'll try again tomorrow night after my computer finishes loading the new project.

avatar image xlar8or Dec 21 '17 at 01:04 AM

Surething :)

avatar image HeadHunter625 Dec 22 '17 at 09:31 PM

I got it, thanks!

avatar image HeadHunter625 Dec 22 '17 at 09:31 PM

Idk how to make this answer "Solved"

avatar image xlar8or Dec 22 '17 at 10:01 PM

Just click on the check mark on my first answer, if you found it helpful you can upvote it by click the up arrow.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question