Stop sprites overlapping ...

For questions about using Classic.

Post » Wed Feb 03, 2010 11:49 am

Hi.

I'm making a Llamatron 2112 clone atm and have the baddies homing in on the player as they should. Problem is they start to overlap each other. Is there a way to stop this happening? I've set them to solid and that doesn't work and the only collision options are really to destroy them (unless I've missed something). I end up with one big clump of aliens chasing the player.

:(

Any help appreciated.

Thanks.
B
2
G
2
Posts: 12
Reputation: 674

Post » Wed Feb 03, 2010 12:18 pm

I assume you're using something like Bullet behavior for your enemies (as shown in the Ghost Shooter tutorial). But Bullet behavior doesn't automatically support solid collisions.

8Direction does. If you use 8Direction behavior on your sprites (be sure to set the user control to "ignored" with an event) and make them Solid, then they will automatically push out of each other if they're overlapping.

Platform, Ball, and Car behaviors also automatically handle solid collisions. Custom Movement behavior can use actions to tell it how to handle solid collisions. Physics behavior has solid collision too, but it doesn't use the Solid attribute to collide with, rather it only treats other physics objects as solid.


You could continue to use Bullet behavior, or move them yourself with your own events, but you would have to create your own collision events as well to tell your enemies to push out of each other when they overlap. But, eh... it's just easier to use 8Direction, so why not?

By the way, you'll probably want to make the collision masks for your enemies a perfect circle if you're going to use 8Direction, you'll get more natural looking crowd behavior out of them that way. If they're rectangular or irregularly shaped then they might get stuck on each other in weird ways.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Feb 03, 2010 2:03 pm

I was actually just using normal sprites and updating the X and Y depending on the player position. Now I know about the 8 direction auto shoving themselves apart, I'll use that.

Thanks a lot :)
B
2
G
2
Posts: 12
Reputation: 674


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests