Target Cycling system

I’m trying to figure out a system similar to Shadowrun (genesis), Parasite Eve, Dragon age. Player can target enemies within a certain radius and then cycle through them with a button press. I guess it’s similar to tab targeting. I’ve been searching the forums, but its possible I’m using the wrong terms.
I know I would use an array, but I can’t quite figure out what the logic would be.

Is the targeting on continuously, or activated while a key is held? Can the enemies in range change?

Is this top down or platform? 2D or 3D?

All good questions. I hadn’t really thought of any of that since I was mostly just trying to prototype the targeting and see if it works how I want it to. I’ve done something similar in both Pixel Game Maker (I thought I remembered a Gdevelop tutorial on it, but now I think it was PGMMV) and in UE5, but other than using arrays, they both handled it differently.

I’d say the targeting would be constant. Any enemy moving into range radius would be targetable, if they moved out, or the player moved too far away, they would no longer be targetable.

The player character, enemies, and environment would be 3D models (which brings its own challenges I’m aware) but would probably more isometric in view.

What happens is an enemy is targeted, and goes out of range? Does the another get targeted? How is the cycling going to happen - nearest to furthest, left to right or right to left, circular (clockwise/anticlockwise), randomly, something else?

Ok, slight change up since I’ve given it more thought. I’ve decided to lean more into the parasite eve style.

Targeting mode would be activated/canceled by key press, rather than running constantly. (I think this would save on memory cost anyway.)

If target(s) in range, list populates (taken from array) and enemies will cycle based on going up or down the list. So it will just be whatever order the array populates. This list will be visible on screen.

(Some kind of visual indicator of range, a circle around the character, might be good here)

If nothing in range, mode activates, but list will be empty.

Target dies or moves out of range, cycle to next on list or back to first if at the end.

I was playing around in 2D.

Try me. The player is the letter A. The enemies the swirls. The enemies are draggable. Click update to update and left and right to switch targets.
https://gd.games/keith_13579/targeting

It takes the angle between the player and enemies and sets it to an enemy object variable. It adds the angles to an array. It uses the array tools extension to sort the angles. It then numbers the enemy ID variable based on the order of the angles. Once the enemies have IDs they can be looped through and picked by their ID.

events and variables (click to open)

It needs something to handle things like if the angles happened to be identical. And IDK if it should automatically update if an enimy moves out of range or is killed.

It’s one way to do it. IDK if it matches your concept but I like it. IDK how well it would work in 3D. The same concept could be used with distance or maybe a hybrid of distance and angle.

Greatly appreciated. I’ll have to see how this works once I get a chance.

1 Like