Possess unknown pawn

Hi people,

So I already have functionality to switch to another pawn if the user presses the action button when in range of a second pawn. At the moment the pawn that the player is going to possess needs to be in the scene and known (so that I can reference the second pawn in the BP).

In the game we are making though there will not always be a set pawn that will be changed to, it can be a selection of different pawn blueprints.

So, is there a way to return and store the reference to the pawn that has triggered the Event Actor begin overlap function. I am currently trying variations of CastTo but nothing seems to be working.

Thanks in advance for any help that can be offered.

Normaly you would create a base class for the different pawns and save the reference in a variable of that base class. The pawns themselves can be a child class of that base class.

If this is not what you want, please add some more information on what you want to achieve, because first you say that you know how to posses a known pawn and that you want to posses an ‘unknown’ (?) pawn, but after that, you ask for storing a reference to an overlap event actor, which is a known pawn in my eyes.

Thanks for the reply, I guess I was a little unclear, I am not sure what I need, so me asking about storing a reference was the way I know I could do it in code, I am used to C# Unity, not blueprints.

So, at the moment I have a red ball, blue ball, red cube and blue cube. The current BP class simplified works as, if player presses “E” → possess “red ball”. That’s what I meant by already knowing which pawn will be possessed as red ball is the only object in the scene.

Now, if for example I have two of each object in the scene I would want to find out what I have rolled up to, a red ball, a blue ball etc and replace my pre set possess “red ball” with, possess “whatever the player is colliding with”. That’s what made me think I would need to get a reference to the object I am near.

Basically, if there are x number of pawns that can be possessed in a scene, what is the correct way to possess just the one you are near without the BP knowing what it will be possessing in advance, all of the current examples only show you how to possess a single object which is the only option to possess, which is fairly useless as you would need to hard wire entire levels and events.

Thanks a gain, sorry for the long windedness of my reply, just trying to make my question clearer.