How to detect the lowest number?

I have a co-op game and I want the enemy to chase after the closest player. I’m using proximity but idk where to go from there

@CodeAlpaca Help!

1 Like

In proximity, there is an option to output the closest object found. Have the players connected to a parent object and search for that parent object. If you’re searching for the lowest number that’s something different

2 Likes

Could you send me a picture?


heres my code, the globals are for each player

Sorry I guess the title is a little misleading

The globals are called “Enemy”, why is that the player? Also move the “Animation” behavior lower so the wires from the Proximity don’t travel as far

1 Like

Because its FOR the enemy

Still makin that picture?

You said the globals are for the player


Screenshot 2023-04-30 1.16.02 PM

In the second picture, you would select the same Parent object to be the same for both players. Remember, parent objects share their code with the child objects.

1 Like

Will the parent object mess with any of the code?

As long as there is no code in the parent object that messes with it, it will work.

1 Like

Thanks! A’lot :slight_smile:

1 Like

TYPO DETECTED!??!

I saw that and considered adding the comma, but figured it was fine

1 Like

Hey @CodeAlpaca how is this supposed to work


I made the parent now what?

Now the XY will output the closest player. Use those X, Y for whatever movement you make for chasing the players

I know but the way the enemy chases the players is by those globals

How is it going to turn the right one on

What object is this code in? (Player, Monster, or something else?)

Zombie