See if entity is not colliding with other entities of the same type as itself?


(John Andersson) #1

Very confusing title, but I have a block we can call Zach which moves the player if he collides with said Zach.

On some places, I have several Zachs in the same place, let’s call this group a Zach Lewis.

If the player is touching one zach only, then I want the player to the moved to the left by 1 pixel. This works so far. But if the player is touching Zach Lewis (several Zachs at once), then I want the player to move by 1 pixel, not more! Currently, if the player is touching several Zachs, then they all add up to the moving, so if the player is touching 3 zachs at once, he moves 3 pixels per frame.

In short, I want something like this:

type = "zach"

if(player is colliding with this, but not with other zachs) move 1 pixel
if(player is colliding with this, and with other zachs) move 1 pixel

Thank you


(Martí Angelats i Ribera) #2

Do it the other way arround. if (player is coliding with a zach) or the list of zachs colliding with the player. This in code is:

if (player.colides("zach", player.x, player.y)
var list:Array = [];
player.colidesInto("zach", player.x, player.y, list);

(Zachary Lewis) #3

This post touches me and I find it strangely moving. :smirk:


(Martí Angelats i Ribera) #5

Wild FUN COMMENT appeared!