I was just fiddling around and created an interface. So it looks like you just make an interface, then add it to the blueprints you want to communicate with each other… then you create a function in one BP which fires off an event in another. Interesting…
Yes… I can’t wait to master this thing. Then I will be God.
[QUOTE=breen3d;607199]
I was just fiddling around and created an interface. So it looks like you just make an interface, then add it to the blueprints you want to communicate with each other… then you create a function in one BP which fires off an event in another. Interesting…
Yes… I can’t wait to master this thing. Then I will be God.
[/QUOTE]
Yuhp that’s basically the jist of it, the thing that get’s a lot of people is not specifying a target, so imagine you had 3 blueprints implementing an interaction interface call (a Door, T.V and Light Switch), if you didn’t have your target set it would open every Door and turn on every Light and T.V in the world because the call is being sent out to all of those functions, easiest way for object interaction is via a line/ray trace (my line trace below won’t draw anything, it’s just an example) but you can see I’ve added in a “DoesImplementInterface” function to check if the actor I’ve interacted with does indeed implement our interface which I suppose is a sanity check and a performance optimization
With all that being said, interface calls can also work with arrays, so say you did want every Door, T.V and Light Switch, or a combination of them all to activate you can store them in an array and any of the array elements that implement the Interaction Interface will also have the messages sent to them which is bloody awesome if I must say so myself
(Ashamed to say, but this actually the first ever time I’ve made an array haha and again, only an example so it may not actually do anything)
As for event dispatchers, I heard a few times early on that are a lot more resource dependant than interfaces and casts so never bothered to read into them much (there may come a time where I may need to though)
I also forgot to post these links (you may have already seen it thoug
Happy to help :3
Sorry the BP’s are a little messy, but this is how i went about interactions without the level blueprint or interfaces NOTE: I use a trace instead of a collision box
This is my third person character BP. this handles the traces for interactions
Once we determine we are interacting with a door it runs the open door function inside the master door blueprint ( a little more complicated checking if we need a key and if we have it etc but the jist is there
Okay… very interesting. Quick question: What variable type is “Actor Targeted” ? That was my issue at first… I didn’t understand what was suppose to get plugged into the “object” node when casting.
Ah!!! I see! You just create a reference actor variable, expose it and then select the character in the level editor and add the object you want. AHAHAHA! I GET IT!
Uhmmmm. Not really. You want that variable to be “hit actor” from that line trace. Otherwise, you’ll end up always interacting with the same object in the level.
As did I. If you merely want a static interaction, what you said would work. However, if you want to change the object you interact with, then you’ll need to set this during runtime w/ blueprint.
That’s a wrapper for a line trace. No clue what settings the line trace inside has though. You can find tons of line trace examples. Try one of these.
Inside that function, perhaps. If not, then you’d need to manually promote it.
The two pins represent the value to be set and the object to set it in. Top pin is value, bottom is object to set it in. Most pins labeled ‘Target’, at least on ‘default’ nodes, will be the object that you’re performing the action to/with/on. Think of it like a phone call; the Target pin is who you’re calling. The Value is the pizza you’re ordering.
Ah thanks. So he is using C++ then? I think it would be fun to explore Visual Studio at some point, but unfortunately every time I tried to launch the program in the past I ran into errors. Ran into a road block on the Twin Stick Shooter tutorial and had to set up the base character class in BP instead.