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"

I have been looking, but i do not understand how to make selectable characters, or really how to "posses" anything

As the title states, i can get a character to move, but i do not understand how to simply change characters

Lets say i want to make something that has multiple turrets, but the player can only control 1 at a time

How do you go about making that character "control" that object?

I have tried using the posses function, but im either not getting it right or i am using the wrong function

LIke, my ultimate goal is to make multiple selectable characters that i can spawn in (think like tf2, pyro, heavy, ect) and then give them the ability to either man turrets, or what have you, and i want to understand how i should be telling ue4 to fire the interactions between these characters

All help would be massivly appreciated, i have been searching around i have not been able to find something this simple in like 6 hours of searching

Product Version: Not Selected
Tags:
more ▼

asked Aug 20 '14 at 02:34 AM in Using UE4

avatar image

Signod
1 2 4 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Are you looking to use blueprint or c++? I can show you how it's done in blueprint but if you're using that, but for future reference you should specify your question category as either c++ or blueprint.

Regardless, here's my BP solution, it will look messy and complicated but I will just try to be elaborate as this annoyed me as well.

There are two main things to understand here, the playercontroller, which is the interface between the player and their character, and the character. So while the character may die or respawn the playercontroller will remain. Think of the playercontroller as representing the player themselves who may be manipulating various characters or vehicles.

I don't know how your setup is, but chances are you'll want to create your own playercontroller, make a function for possession like mine here: http://puu.sh/aZWIX.jpg

I created a variable in the playercontroller called "possessed character" and a variable in the mycharacter class called "control" and by setting each one, you can access them in either's blueprint.

So all you need to do is call that possession function, using event begin play and likely after the character dies and is respawning. Instead of spawning mycharacter and possessing it though, you could use a switch statement and spawn any kind of character you want and possess it the same way. You might want to make a menu in UMG where you can select which class you want to spawn as. I would probably make a separate function for controlling turrets but it will work basically the same way, except instead of spawning a character and possessing it, you'll get the variable for the turret and possess it. There are a few things I can't advise you on because I don't know the specifics of your game design (do players disappear when manning a turret? Do they get inside it? Can you switch between turrets on the fly? Do you possess nearby turrets or pick them off a menu?)

The last thing to do is to set the player controller under "world settings" (which is on the right side of the editor by default) in the game mode information to the player controller you created so your code will actually work.

Let me know if this helped or just confused you more, or if I misinterpreted your question. Start by just getting your own playercontroller to possess your character and work from there.

more ▼

answered Aug 20 '14 at 03:54 AM

avatar image

VedgyB
226 14 13 35

avatar image Signod Aug 20 '14 at 04:44 AM

This is sort of thew answer i was looking for, i am not actually building any sort of game right now, i merely do not understand the interaction between how you gain an avatar (of any sort) in a game and how you switch said avatar to other things.

This line in particular helped me the most here:

There are two main things to understand here, the playercontroller, which is the interface between the player and their character, and the character. So while the character may die or respawn the playercontroller will remain. Think of the playercontroller as representing the player themselves who may be manipulating various characters or vehicles.

Followed by:

The last thing to do is to set the player controller under "world settings" (which is on the right side of the editor by default) in the game mode information to the player controller you created so your code will actually work.

I will load some blueprints up tomorrow and try to get a roughshod thing working, i still kind of dont understand exactly where to place the "possess" script

That is, i don't know if that possession is supposed to be on the actual pawn itself, or on the player character, i could not even get a simple "press f to possess" button working, it was if the game was just ignoring the blueprint, the debug mode did not even fire the lines to show that the f key was being pressed

Thank you very much for your help, after this i will need to figure out how to load say 8 different characters for 8 different players, i assume you would store the characters in some sort of array, but thats is for later, i need to get some interaction going first

avatar image rodstone Aug 20 '14 at 05:22 AM

I know this will confuse things but you don't need a playercontroller for this to work. I don't understand it either.

avatar image VedgyB Aug 20 '14 at 07:02 AM

If you take baby steps towards implementing this it won't be too bad.

You want to create the function I showed a picture of in your playercontroller blueprint. this function should be called whenever you want the player to take control of a character.

When you set the default playercontroller in the game mode, in the panel I described before, as far as I understand, every player is assigned that player controller. Any time possess is called within the playercontroller blueprint, that player will now be possessing whatever the possess function has as an input, so, in my example, the mycharacter actor. I think your best bet for multiple classes is a switch statement (look for the node switch on name). Maybe you already know this but a switch statement basically takes an input and can do multiple different things depending on what that input is. So if you can get a menu to save a variable for the class they selected and pass that as the input for your switch, you can have different actors spawned and possess them the exact same way.

http://puu.sh/b06Fu.jpg

It will look something like the above screenshot, except for the purple pin which says class, you want to create new classes for each character and select them in that dropdown box.

So this is a function that you want to call whenever the player spawns in, so call it after event begin play and at the end of a respawn function. Here's the event graph for my player controller. Ignore the array being shuffled, it's specific to my project.

http://puu.sh/b06Sp.jpg

I am not a super expert by any means so someone might offer a more elegant solution, but hopefully this gets you on the right track.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Under the blueprint menu at the top, select game mode create, and in that gamemode you get to choose the default pawn. It's this default pawn which is what you will automatically possess when you start playing. Under world settings you choose which game mode to use. That is all that is necessary. Other things to take control of input are necessary in different scenarios but shouldn't be necessary unless something else is stealing them away

So in your map, you place down a player start and what will spawn there when you hit play is the default pawn. In that default pawn's blueprint you need to put functions with what to do with your inputs.

Be sure to set up your inputs in the project settings and don't "hard code" them into your blueprint.

Good luck. This was a major stumbling block for me when I started

more ▼

answered Aug 20 '14 at 04:33 AM

avatar image

rodstone
76 11 16 90

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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