So before I get into the question, I should point out that I am using the shooter example project as the base for my project (Because it had characters, animations, networking ect.) and I am using blueprint to script different gameplay mechanics (in the playerpawn class)
This method was working fantastic, until I came across creating a pickup.
I have created an item that changes a boolean to true, and then destroys itself, said boolean is used in a branch, and so whenever he picks up the item, it allows his keypress event to go trough whenever he presses “x”.
The problem being that whenever one person picks up the item, it allows everybody to activate the perk when they press “x”
Am I going about this wrong? Why isn’t this working? Like I said, everything is being done in the player pawn.
Thanks in advance! Any help is much appreciated
(Yes I know its sloppy to just use any random key event, i plan on making this all customization to the player later on when its more necessary)
I’m not sure I quite get why I would need to use the other actor output, does that allow me to get the player that walked through the object? How can I actually use that variable to help me?
Here is the pickup/player pawn blueprints, i labeled both images at the top to make it easier to identify them:
Thanks, that helped, sorry also if I just deleted those comments, i was trying to convert it to an answer. I have no idea why that worked though, could you explain why that did so I can walk away from this with some understanding? Thanks so much.
overlap events return a reference to the actor they overlapped, called OtherActor, and you can cast that reference to a specific blueprint, to use its functions, or you can call an interface function on the OtherActor, and if the OtherActor is a blueprint that implements that interface, it will receive that function.
Oh ok! That makes more sense! Could I get the player who executed a keypress event?
the pawn can store the reference when it overlaps an actor, and use GetController cast to a player controller to enable input on the OtherActor.
or the pawn can EnableInput (by using GetController cast to a player controller) on actors OnBeginOverlap, then disable input OnEndOverlap. this will allow the actors themselves to receive input events directly.
a more advanced method is to use dot product to compare which objects you are looking at most, and use that to either enable input on the actor closest to the center of view, or keep a reference to that target actor, so you can call functions on it.