How to discover Variable from multiple actors on screen?

Hi,

I have a project where I have several actors(targets) on screen, and want to press a alphabet key to target the actor with that corresponding key.

Each target asigns itself a Key on spawn.

The player assigns a new key on Key press for itself.
Screenshot 2022-11-12 144636

I’m line tracing to each target within range for calculating grapple features, but I would like to somehow pull the “assigned key” from available targets and use that key to grapple to it.

I’m unsure how to pull this “key variable” from multiple targets on screen.

Thank you for any help?

Each actor assignes itself a random key? How are you keeping them from duplicating the keys?

Hi @pezzott1, thanks for your response.

Currently when the target spawns, it just grabs a random letter from an array.

I haven’t yet figured out how to not duplicate.

You could store an array of keys in your pawn, and each actor would take a random key for themselves by removing it from the array.

  1. Pawn:

  1. BP_Grappletarget:

I hope it’ll be helpful.

My Products

@Supremative Thank you. This looks very helpful to solve for duplicates.

Any idea how I could detect the key associated with a target when I can see multiple in game?

BP_Grappletarget:

Pawn:

If you need only onscreen actors:

1 Like

@Supremative I know this is probably extremely easy but I’m scratching my brain on remembering how to do this part I circled in red. In an earlier image you referenced a “KEYS” and “Local Key” variable. This one only says “Key”, is this a new variable? I’m unsure hot to connect it in a way that shows “Target----Key”

Thank you for your help!

Pawn:

LocalKey - a local variable in the function GetKey. It holds a random item from the array.

KEYS - the array of available keys.

BP_GRAPPLETARGET:

Key - a new variable
image

Perhaps you should give the variables more specific names to avoid confusion.
For example,
KEYS - AvailableKeys
function GetKey - GetRandomKey
Key - AccessKey

When we originally spoke about this, the 2nd screenshot contained a suggestion of how to do it:

Not sure if you missed it or simply did not like the approach; if it’s the latter, ignore what follows.

I’m line tracing to each target within range for calculating grapple features

That’s the problem, you’d first need references to those and then filter for range. Consider implementing the method I mentioned. Using the GetAll nodes for this is too cumbersome and can become slow if you need the updates often and / or there are plenty of objects.

You will, ofc, need the dot product to get the direction-valid ones.

1 Like

Thanks! Was searching for this solution