How to add a child actor to a BP and use it's inputs

I have a system set up so I can equip different child bps onto my main player. I’m having an issue with one of them as I want the child actor to fire projectiles when space is pressed however it doesn’t do anything.

Here’s the code on the child BP, but it doesn’t run when I hit space bar on the player with the child actor attached

Is the input enabled in this actor - it is disabled is by default, and for a good reason. In a more traditional input setup, you’d have the player process a key press and tell the CAC’s actor to do the thing.

Would that work for you? Keep the input in as few places as possible.

Oh so I could do a check to see if the Child actor is on the player and then tell it to do that line of code in the player bp while casting to the child actor?

Are the CACs added dynamically?

I can equip different child bps onto my main player

Sounds like it.

Yeah, the basic premise is, I have a ship, you can attach a ram, sail and canon onto it. The ram and sail increase stats passively so they’re easy to set up but where I’m adding the canons and want them to receive an input it’s not doing it.,

1 Like

I can think of a couple of ways to handle it in an agnostic way. Gimme a me sec.

@ZaharKostic, that’s one way, precisely:

  • if this is the ship that presses space:

image

  • a CAC’s child actor could:

1 Like

I would personally recommend to store inputs at some single class. In this class you can create Event Dispatchers for all inputs which you bind to call at player Input outputs. In your case then when you spawn a Child actor, this child actor can bind its events to this class Event Dispatchers without requiring any input on self.

38866bc1a3e2caddcfb0b5a28f743621

Hmm, I think I’ve set it up like that but it’s not working, I’m not sure if I’ve missed anything, I’m really new to Event Dispatchers. I really appreciate the help.

Technically you can:

image

And enable input on the CAC’s actors:

image

But then ALL space events will fire. It could work in some scenarios but will create a little debugging nightmare if things go wrong, as they often do.


Hmm, I think I’ve set it up like that but it’s not working, I’m not sure if I’ve missed anything, I’m really new to Event Dispatchers. I really appreciate the help.

Looks OK at a glance providing it’s the possessed player. Silly question, you said Ship but this is a Character class. Is this intentional?

Does this print when you:

Yeah it is printing that. Not intentional I guess, it’s the only thing you’ll be controlling in the game so I just thought I’d make it a player. The thing is, I have the code set up to fire the basic set of canons that are default on the ship. So space does work like that.


eb71d59f575524cf897b56def96e331d

Use a Pawn class instead. A character will give you a headache. It will fight you. And it is likely to win, just grind you down. :innocent:

A pawn like this would give you some controls out of the box, and none of the fuss:

A character is great if you have arms, legs and bi-pedal movement. A human form.


Does this Begin Play trigger:

image

Perhaps it’s important for us to know how the new cannons are added? Do you Set Class on CAC or use some other way?


Btw, there’s also a way to get what you need without using CACs which are, generally, horrible to work with. Not sure how far you’ve got with the progress.

Yeah that’s a good shout honestly, I can’t get rid of the default capsule anyway so it’s an odd shaped collision for the boat.

I have a few child actors added to the blueprint itself named various thing “Sails, Ram or Canons” then on a UI piece, when a button is pressed it will set that child actor to use the corresponding BP

1 Like

Does it print in the actors you’re swapping to? And is the cast successful?

Sorry I missed that part :sweat_smile: Yeah when I select it on my UI and it equips, it triggers that print.

And this?

Yeah it is successful

Are you calling the dispatcher:

In the ship character / pawn?

Yeah, I created the event dispatcher in the ship character though, should I have made it in the child?

1 Like

Could you retrace these steps:

  • a pawn with a CAC:

I give it a new cannon after a while.

  • the cannon actor looks up the owner of the CAC and registers with its dispatcher:

This pew, pews when space is mashed.


If the setup does not work, there might be something about the project we do not know about yet.

1 Like

It works!!! Thank you! Now I just need to move everything over from a character to the new pawn.

1 Like