Separate objects and move them on the y axis

How do I…

In a top down perspective

Detect collision between two instances of objects in the same group and move one of them up or down on the y-axis so they are not exactly on top of each other.

What is the expected result

Object A moves forward using forces and stops to fight the player. Object B moves on the same X axis toward the player, but when B collides with A, either A or B should move a little up or down on Y axis.

What is the actual result

Using “Separate objects”, Object B pushes Object A in front of it, past the player, then comes C and does the same to B, D to C etc in a long line.

Can you post a screenshot of the events and the scene? It’s a little tough to visualize what you’re trying to do. A video link to maybe YouTube or a very short animated gif would be even better. Even a simple line doodle marked where you expect everyone to go would help you get a quicker answer.

A fights B. Who does C fight? Are the coming from the same places or anywhere 360°?

Sorry, I did not explain that well enough. Im getting older and english is not my primary language :stuck_out_tongue:

The Object A, B, C, D etc are enemies that spawn in a line and walk toward the player on the X axis.

Object A (enemy 1) spawns first, moves toward the player using forces and when in collision with player object, stops and starts fighting.

Object B (enemy 2) spawns behind A (enemy 1) and walks the same path on the same X axis. Repeat for C (enemy 3), D (enemy 4) and so forth.

Right now when B reaches the point where A is standing and fighting the player, it will push A in front of it past the player and then stop when I use the “separate objects” on collision between enemies.

I will show the code and try to film it if I can figure out how.

My enemies (A, B, C etc) are both in the group Enemy and EnemyMelee for now.

After spawning an enemy, they will start moving toward Players base first but when a player unit enters the screen, they will move toward it instead:

When enemy collide with player:

I tried to put this on them right now (standalone event) without anymore modification:

The result is, as I explain, the enemies push the one in front and then stop. I want them to stand on the same X point but move up or down a little on the Y axis.

I’m not sure how to go about this. If I can I’ll do some testing. Hopefully someone else here can help you in the meantime.