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"

Cast to character, but multiple playable characters? Methods and tips?

Is there any good way to handle casting to a character, but not make it character-specific? As in, I have multiple playable characters, the player can select which character they want to play. But when setting up various functionality, especially when following tutorials, the cast to [insert specific character] is used extensively.

Now, I have gotten around this so far by using BPI messaging and events and all AI interaction has been fairly simple to set up this way. Currently I am making UI and inventory/equipment/skill systems and it's getting very convoluted and difficult to keep track of.

So I was wondering, does anyone have any tips on ways to be able to communicate with character blueprints without referencing a specific character blueprint?

I would prefer not to use get all actors of class at all if possible because of the taxation on the engine.

I've been exploring the parent-child setup, ie you have basic character blueprint, and all your different playable characters are essentially made as a child class of that character blueprint. Anyone got any insight on this? The idea would then be to store all the shared variables and functionality, like item inventory, equipment, and various UI interfaces, in the parent blueprint and communicating with that.

Product Version: UE 4.21
Tags:
more ▼

asked Feb 06 '19 at 02:14 PM in Using UE4

avatar image

Crowley Caine
693 8 10 16

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

1 answer: sort voted first

for storing things like stats and other qualities that are common among many characters, inheritance (parent child) is the way to go. by taking advantage of inheritance you wont have to create a variable in each class for something like health, the child classes will inherit it from the parent class. it also means that you wont have to cast to multiple classes when trying to get the stats, you can just cast to the parent class. its like the relationship between pawn and character, characters can do everything a pawn can do and much more. so your parent class would have the basic functions and variables and the children would have things specific to the role like abilities.

more ▼

answered Feb 06 '19 at 02:42 PM

avatar image

ThompsonN13
10.1k 33 10 25

avatar image Crowley Caine Feb 06 '19 at 02:44 PM

Yeah that's exactly what I was thinking, plus it eliminates the need for this constant BPI messaging and events, it simplifies everything. Thanks a lot, if you have any general tips on that I'd love to hear them.

I've essentially set up a basic character now which has a fairly big combat system, it can receive XP, it has talent trees, health etc. Now all my characters will have different combat systems. Any tips on how I should proceed, should I just start over with a parent class now, or should I complete a full character, take out the specific stuff and then transport that to the child class?

Another option I envisioned was doing kind of cascade from Cast to [Specific character], ie if cast fails then go to the next etc, but that seemed... dumb.

avatar image ThompsonN13 Feb 06 '19 at 10:46 PM

depends on how much youve already completed. its really not hard to recreate what youve done but it can be tedious. another option would be to create the base class then reparent the classes youve already made. to reparent a class you just need to open the bp then go to the class settings and in the details panel theres a parent option, just change that yo the base class you created.

another little tip is make sure you go into the my blueprint section of your bp, click the eye icon with a down arrow next to it, then check the box for show inherited variables.

one last thing to note, child classes inherit any scripting and custom events from the parent as well. so you could have the damage handling in the parent if you wanted. i used this once for simple ai by creating custom events for abilities, basically just ability1 ability2 etc, that way the children could have custom script but i could use one behavior tree that just calls the generic event.

avatar image Crowley Caine Feb 06 '19 at 11:42 PM

Thank you, that is good advice. Recreating it should be fairly simple, it's just a matter of copying the code and recreating the variables I suppose. Few hours and it should be working, barring some unforseen hiccups. I decided to complete a character implementation first, to kinda nail down functionality, then work on parent/child now that I know I can use a parent to cast to it should go a lot faster than trying to keep my tounge straight with the BPI stuff. I love BPI and it's amazing for debuffs and sending experience to my character upon death etc (though it can also be done by cast of course), but when you're doing stuff like UI widgets it is extremely cumbersome.

So far I have combat with combos, take damage, do damage, visual effects like weapon trails, blood splattering on the ground, xp and levels, skill trees, inventory and equipment nearly done. AI with range select and varying attacks, follow, search, go back etc (still got a problem with them returning though as they bump into each other and prevent movement - haven't had much luck with turning off collisions there).

Amazing what you can do with unreal in a month when all I had was three cylinders in maya. Attacks alone are 28 different animations for a single character and those are just button combos before I start doing special skills. Fun stuff though.

I don't use behavior trees to be honest, I found them very finicky and problematic whereas blueprint AI is so simple. I do implement actions in a similar way, I seperate functions and behavior and then add in the parts I need for different enemies.

(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