How to get the player controller that used the blueprint?
For example, how can i get the controller of the player that used an item in his inventory, inside that item’s blueprint?
Please help.
And also, if that used item spawns an actor, how can i send this player controller id to that actor as well so that actor knows too?
The question is worded strangely, not sure what you mean by using the blueprint. That really is dependent on your game.
The usual way is to pass the reference of the controller along from the point that the event occurred. If it’s a direct button press then it’s on the controller itself, if it’s a trigger volume in the world then you have the Actor that did it, you can get the Actor’s controller and cast to your type, if you are mouse clicking into the world again you have the controller at the button click. Just pass the controller as a reference.
In general, though, you want to define the interface to your objects such that important information is passed into the object.
If an object is used through a collision volume, then the pawn that collides/overlaps has a controller.
If an object is used through UI, then the UI View has an owning player controller.
Pass along those controllers to the blueprint action for the inventory item, to make sure you get the right player.