Hello Guys!
I have started developing with Corona SDK again recently and want to develop my first commercial game.
However, I came across some problems by moving objects to another movable object.
Let me explain a few things first:
- The app is playable in landscape view
- The player is located on the left side and can move up and down (Y-Coordinate)
- Enemies spawn on the right side and move to the player location
- When the player moves, all enemies should follow him
- The player can shoot the objects

I have managed to archive this by the following methods
local function spawnEnemy() local zombie = display.newRect(midGroup, screenWidth, math.random(0, screenHeight), 100, 100 ) zombie.isEnemy = true zombie.name = "zombie" zombie.life = 10 physics.addBody(zombie, "dynamic", {bounce=0, radius=50}) transition.moveTo( zombie, {time=(zombie.x-player.x)\*speedFactor, x=playerGroundWidth/2, y=player.y} ) table.insert(zombieList, zombie) end local function movePlayer(event) local diffY = player.y - event.y local finalY if (event.y \>= screenHeight - 100) then finalY = screenHeight - playerHeight / 2 else finalY = event.y end transition.to( player, {time=math.abs(diffY) , x=player.x, y=finalY} ) for i=#zombieList, 1, -1 do local speed = math.sqrt(((event.x - zombieList[i].x) ^ 2) + ((event.y - zombieList[i].y) ^ 2)) transition.to(zombieList[i], {time=speed\*speedFactor, x=playerGroundWidth/2., y=event.y}) end end
However, there are a few problems
- Whenever the player moves, all enemies move to the new player position. This is ok, but the enemies should not move through other enemies. So each enemy should move closer to the player, but can’t pass other enemies if they are infront of them.
Imagine it like a bunch of kids are following an ice cream truck. They can’t go to the seller all the same time, they have to buy the ice one by one
2. The same goes when the player kills an enemy, so all remaining enemies move closer to the player. Guess it can be archived with the same method?
Of course the enemies can’t pass the player ground, I’ve added a static physics body to it.

Do you have any suggestion with this problem?
Best Regards