How to stop actors overlapping?
RedRobo
Member, PRO Posts: 682
Hi everyone
I have a bunch or actors that are randomly spawning within a square area. Does anyone know of a way to stop them spawning on top of each other? Is there a kind of check that the actor can do after it is spawned and if it is too close to another actor re-spawn itself?
Comments
Do you have collisions in the actors?
I think the simplest way would be to check if the actor is colliding with another actor once it is spawned. If it is colliding, destroy it and re-spawn it at a new location.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Set them to collide with each other, if they spawn in the same place or overlapping they will push each other aside so they are not overlapping - you might also want to switch fixed rotation on to stop them rotating as they order themselves.
They sound like great ideas guys...thanks a lot:)
I will give them a go and let you know how I get on
Not yet but that's the next thing I'm going to try...