I have a character. This character has a weapon. I need to pass some information to that weapon from the character. The problem is that character can have any of some variety of weapons. And I want this weapons to be different, with different features. So I want this weapons to be different blueprints and I just could change them whenever I want in game. But they should still be receiving data from character…
I tried casting but wasn’t been able to figure out how to do that to different blueprints. I’ve been able to cast to only specific blueprint, but not to object reference. And I can’t understand why…
I’m not sure how this looms, but I think blueprint interface can help you.
Sorry, but this doesn’t help even a bit…
If you’re trying to get one blueprint to talk to another blueprint then yes, Interfaces are what you want to use. Interfaces can send a message to a different blueprint and I think can get a response back.
Blueprint Interfaces.
One of a few different ways you can do what you want, however it is likely the best for your situation once you wrap your head around it. Here are a few tutorials explaining what they are and how they can work for you:
Unreal Engine 4 Tutorial - Interaction & Interfaces - YouTube - UE4 How to easily communicate between blueprints - Blueprint Interface Tutorial - YouTube - WTF Is? Blueprint Interface - YouTube
Official Version: Blueprint Communications | Live Training | Unreal Engine - YouTube
Once you’re done with those, you should have a good idea on how to basically add an Interface to both your character and your sword and your basket, thus making each do exactly what you want them to do based on the node code you put in their Message Receiver. Added bonus, you can add Children and make them do even more than their Parents do, or different things altogether.
Thanks, I’ll look into these. Though, I already get it working thru casting. Still needed to have a base class for weapons in general. But I guess it’s ok for me in this particular case. I can have many weapons, and cast works to exact referenced child of that class. So it solves the problem. But still thanks for links, now I’ll know where to look if I’ll need another way to communicate between blueprints.
In my POV you describe the typical scenario for having a more “abstract” Weapon BP that only holds the basic information and functions like Structs. Then you make Child BP’s for each Weapon. And you use the abstract Parent class to cast the object to.
Same goes usually for Characters that you have a base Character class with the structs etc, and just extend those so you can easily cast everyone to the base character class for ease. Hence typical OOP ideology.
Interfaces are usually used programatically for communication between objects of very different types.
In your scenario with Weapons and similar it is more fitting to use a base class as described above, and seems like you are using (reading your last post now).