Hi,
I need to reference (through a variable) an Actor Component in a (User Widget) blueprint. I followed a bit of tutorials and they all say to set a variable that references the Actor Component, but it will be empty by default still (for some reason). So I need to actually set the variable at the beginning. Only thing is I’ve tried every node that could reference or get the Actor Component but it does not appear anywhere, only Actor and other things but no Actor Component or directly the actor component itself. It’s like it’s invisible, but it still appears inside the variable. Am I crazy? What am I missing?
The reason is very simple, how does the system know which actor component you’re talking about?
Even if it’s one kind of component, you might have hundreds of them in the level.
The problem here is that the Actor Component is not being hosted by the player character. I would like to reference the actor component itself, regardless of where it is hosted (because I’d like it to work with any actor when I just put it in)
That’s probably your problem, then. You can’t reference it in an abstract sense, you can only reference an instance of it. IE, it does have to be a component in an actor.
Oh okay then, would there be any way to reference the whatever actor is currently using it? Like a node that would be something along the lines of “Get Active Actor Owner” or something?
No we’re cookin’
What’s the situation? What is it hosted in, and what relationship does it have with the widget, if any?
So the actor component is currently being hosted by an actor (a character in my game). It contains code for the logic of a dialogue system that I first wrote inside the actor, but realised if I want multiple characters to have this logic I need an Actor Instance, so I moved all the code inside the component.
I would like this component to be hosted in whatever character I want the player to be able to have a conversation with. Which is why I would like to reference the component and not necessarily a specific actor.
The widget is simply the text that appears when the actor component detects that the player presses the interact key.
Perhaps I could use the “Get all actors with tag” node and apply the same tag to all actors that can have a dialogue. However I don’t really know how to select the actor that is currently active from the array
I’m more of an inheritance fan than component.
When can’t they all just keep a copy of the component, ready for when the player comes along?
Or, you could leave the interaction code in the character, and just have other characters inherit from it.
At any rate, you can use a get all actors and ask which one has the component, I guess
They could all keep a copy of the component, but a. wouldn’t that affect performance although now that I think of it probably not, and also b. how can I reference any actor that has the component so that the Widget can fire off not just with one set character? (Is there a node to get all actors that have the component so I can plug it in the “Target” input of the get component by class node?)
Regardless I appreciate the support.
The player has to interact with the actor that’s housing the component. That’s how you know which component to talk to.
Interfaces are good. The player sends a message to actor A, just because that’s where the line trace ended up ( IE player is standing in front of actor A, or however you’re deciding which actor to talk to ). The referenced actor can pass the message to the component.
@Everynone You’re a big actor component fan ( I seem to recall ). What would you recommend?
Here is what I have so far. I measure the distance of the player character from the array of actors and it should pick the nearest actor and use it as a target.
That seems to have worked! Thank you for all the help, now I’m gonna have to figure out how to display different dialogues based on certains items collected or which character talks
Anyway have a nice day