Multiple characters share common events via interface

Hello,

I’m trying to setup multiple characters to share common blueprints.

Here’s what I’m trying to do: I have multiple games with a single character connected to it, so I can quickly change the gamemode and it automatically changes the camera, inputs and stuff.

But now I want all my characters to share similar “code”, and I’ll be able to add/remove the event message I want that gamemode to use.

Problem: I’m unable to get the Fire Beam and Fire Rocket to trigger at all (the InputAction Fire in the characters work, tried with Print Text).

Could this be related to the parent class I’ve chosen for the Fire Beam and Fire Rocket? I’ve chosen the Actor.h parent class for those. What should I use instead?

Is this the right way of implementing this? Or should I use Blueprint Function Library or something instead?

Hopefully these images will help with what I mean/want to do.

Character: First Person

Character: Third person

Interface

33849-interface.png

Fire Beam (First Person)

Fire Rocket (Third Person)

Thanks for your time.

// Saucy

Where do you call those events? (in which class? Your character as well?)

Because the target for an interface call means the object / actor which should receive the event. If you plug in self… well then you might as well use a custom event as it’d do exactly the same thing :wink:

Every image you see are separated in their respected files, so I have 5 files right now. So first_person calls fire_beam via interface message, and then fire_beam should do it’s thing (shoot a beam).

I’m not sure what I’m supposed to inject into the target of the interface message. Basically I want fire_rocket and fire_beam to shoot from the character that has those interface message calls.

Interfaces are pretty new to me, so forgive me for not understanding how they suppose to work. Am I better off making all custom events (fire_beam, fire_rocket, etc) in a single file and use that to call from the characters instead?

No no. That’s actually the usecase for interfaces. All you need is to insert the target BP inside of the target pin.

You could even use the same interface and just switch the target depending on the mode or something like that. All you need is just the reference to that other BP.

Alright, thanks! I’ll play around with it.

I followed this tutorial: - YouTube

It all works but when I tried to move almost everything to an interface event, everything stopped working. I still don’t know how to reference the right blueprint. Because the blueprint I want doesn’t exist in the world, it is spawned by the character pressing the Fire button.

Image album: http://imgur.com/a/sQof6#0

Wait wait wait… let me get this straight. You’re trying to spawn the projectile from within itself? O.o

And that worked in any version? That is impossible. Straight up. No way you can spawn something from within itself. You can spawn the same instance a second time but if you just want to spawn a single instance of it you need to do that somewhere else. What you want to create is a paradox which therefore can not exist.

  1. You can only call that function when the projectile exists.

  2. The projectile can only exist when you call that function.

See the issue? What you need is a simple spawning function inside of a weapon or your character.

Aha. I thought I could make the projectile a reusable thing so if I add more characters they could use that if I wanted to.

I’ll keep it simple then and keep each character fire projectile in the character blueprint.