A question about multi input

Im attempting to make a fireball something however I want to I make it so that i have to press a sequence of buttons first (example: 1, then 2, then 4 and lastly to release the fireball press right mouse button) though i cant really see how? Thanks in advance.

  • I created a BaseSpell Actor Component with a custom event CastMe
  • I created 3 children inheriting from the above component - Fireball | Lightning | Heal
  • I added those 3 spell components to the actor - Player Controller here, to make things easier
  • at Begin Play I populate a String | BaseSpell Map (Dictionary) with a KeyCombo | Spell Component

  • Pressing Any Key, providing it’s numeric, appends that letter to a string variable Accumulate String Combo
  • Pressing Right Mouse Button finds it in the Map; if the combo exists, the appropriate component’s CastMe event is fired.
  • Reset the Accumulate String Combo variable

This seems to work well, it’s simple, reasonably modular, allows you to override children’s custom events and can be easily expanded. Even updated dynamically, since you can just spawn and swap out the spell and their combo in the map.


It, of course, can be vastly improved. But again, it depends whether you’re dealing with 8 or 800 unique spells.

I’m getting an “The type of Target
Array is undetermined. Connect
something to Length to imply a
specific type” error? wtd?

Could you show a screenshot of what you’re attempting?

Fixed that, though ran into some other trouble. I’m not exactly sure what you meant here:
I created 3 children inheriting from the above component - Fireball | Lightning | Heal

I added those 3 spell components to the actor - Player Controller here, to make things easier

Fixed that, though ran into some other
trouble. I’m not exactly sure what you
meant here: I created 3 children[…]

You can create components just like you create actor blueprints in the Content Browser (second from the bottom):

259149-capture.png

You can then right click them in the Content Browser to create their children who inherit whatever you put in the parent. And you can then add them to blueprints just like any other component (including spawning them dynamically).

You’d put all the variables, functions and any other elements that define your spell. All the shared information goes into the parent, and the unique, child-specific stuff goes into the inheriting child

Common stuff like mana cost, range, damage can be stored in the parent - all spells need it. But radius is needed by the fireball only, so only the fireball should have this variable. Inheritance will ensure the fireball has all the other variables, too.

For something simple, you do not need to worry about it too much but if you ever decide to grow it, good code organisation is pretty much indispensable, especially in BPs where everything resembles a rainbow spaghetti after a while.

Those components are like templates for the spell the player can cast. Once the spell is cast, the component can spawn an actor that represents in the world. Most likely when you call CastMe.

Turns out ive been using actor and not
actor component…

You probably could but there’s no need.

No worries, perhaps you should consider some general reading about inheritance. Do consider investing 20 minutes into this:

It might save you a week of hair-pulling later on. Great intro to what components are!

Turns out ive been using actor and not actor component…

And I’m a bit confused, is there supposed to be anything other than “CastMe” inside of the actor component?

I see. Please excuse all the questions :[] this is pretty complex for someone who started like 2 weeks ago :wink:

If you still have the Component, would it be possible to post a screenshot of it (instead of PC) so i maybe have something to compare mine to?

Things is I’m not really sure what to do after creating the “CastMe” note :||

Have a look at this one as an example:

https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/1547020-how-to-make-potion-that-heals-over-time?p=1547372#post1547372

I posted this last week or so. It creates a very basic temporary healing effect and then terminates it once the healing is all done. It can be used for a potion or a heal spell. In your case, the CastMe could spawn a component effect like this for the player.

Perhaps you can somehow adapt it to your needs.

edit: now that I look at it after a week, I’d it do it slightly differently, but that’s pretty normal. Still, just an example.

I’m not sure what you expect here. You asked for a way to trigger an action by pressing a combination of buttons. That’s what I’ve provided.

How your spells work (what the CastMe node does) is up to you at this point - you need to implement the mechanics of the spell.

- the Heal would target the player and restore the health points

  • do you have a player health system working already?
  • can you work with materials to visualise the healing?
  • can you work with UMG to show the player’s health recovery?

- the Lightning would deal damage to a single target

  • do you have enemies with a health system that can react to damage accordingly?
  • do you have a single enemy targeting system in place?
  • can you produce Cascade / Niagara particle effects?

- the Fireball would affect more enemies in an area

  • are you comfortable working with collision volumes and applying area damage?
  • is physics involved?
  • do you have the material / vfx for the effect?

Each effect needs to be implemented. Having a CastMe event in each component allows you to override the behaviour effortlessly. By calling it on any component, you’d execute the respective version a particular component implements. It’s a bit like a virtual function if you’re familiar with OOP.

That’s a lot of upfront work to get everything going. You may need to break it into chunks and work on a single element at a time to get comfortable with blueprints before you can pull off a working spell system. It’s moderately complex.

I see, seems I’ve got a lot do next week :slight_smile: