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"

How to character swap?

I know there are some really bright people on these forums! Alright, so I would like to have my third person character game to be able to switch between three characters. Each character has their own animation blueprint, and character blueprint already set up. I would ultimately like to set it up that two of the characters are AI allies, and the other one would be the controlled character. Each will keep their own stats i.e. health, current equipment, etc. but share the inventory. So does anyone have a good practice to switch the playable character via event or event dispatcher? Would it be better to just change the mesh or the blueprint entirely?

Product Version: UE 4.20
Tags:
more ▼

asked Feb 12 '19 at 12:39 AM in Blueprint Scripting

avatar image

Limp_Noodle
9 2 2 5

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

1 answer: sort voted first

When you have 1 PlayerControlled character and 2 AIControlled characters in the same scene, you may want to do it this way:

In your PlayerController, make a swap event that accepts an AI Pawn or Controller:

  1. Unpossess your pawn

  2. Unpossess target pawn

  3. Possess target pawn

  4. Let a new (or reuse old) AI Controller to possess your previous pawn

Depends on how your camera is setup, your ViewTarget should adjust accordingly or you may have to manually set it. By default in ThirdPerson template, it should automatically.

That's just one way of doing it tbh.

more ▼

answered Feb 12 '19 at 12:53 AM

avatar image

Chyros
1.2k 8 4 8

avatar image Limp_Noodle Feb 12 '19 at 01:05 AM

I agree with your answer, however I am not sure where to find the player controller to make an event. I see it as a function that is built-in and I am not sure how to edit that function.

avatar image ThompsonN13 Feb 12 '19 at 02:15 AM

there is a built in playercontroller by default that is based in C++ if remember right, but alternatively you can easily create your own player controller which uses blueprint and set it to be used by default in the game mode. to create a player controller you just need to click the add new button in the content browser (green button) then select blueprint, then in the new popup window look for player controller.

the player controller is probably where you will want to store your inventory as well since its shared between the characters in a way or you could put it in the game mode.

(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