sylvain_l
Member
when you are running your game at 30 fps, making collision checks at each step make generally sens. At 120fps, you should be able to pass some from time to time without real noticeble effect if you aim at the one whose speed are low.Well, this is the only structure I could come up with that worked. I tried simply using direction and speed, but there was no way to get them to stop ending up stuck inside each other.
things like bullets can move fast enough that it make sens. but if something is moving at 30pixels/sec at 120fps your are only moving 1px every 4 step.
also for the get stuck effect, you can have an unstuck(). (often when thing are stuck it's because of a pixel overlap, not like it will hurt much the visual experience of player if you correct that )
"stuck" also can be good, if an ennemy decide to to walk along/on a wall, stuck them on a path and so get rid of all collision checks with wall. (for what I have seen of your game just running it 30sec most of your ennemies tend actually to move along wall once they hit it.)
to be honest you can gain a lot by making your object a little more collaborative. For now it's still a bit over my head. but just a direction if you want to look at. (also seeing your game it feels to me that it can greatly improve the behaviour of the ennemies group)
in groups of fish or birds, they don't need to be aware of the positions of all the others in the group to move in group and avoid collision. just knowing and checking the movement of the 5-7 nearest is enough and ajusting to that is enough. and for bird in arrow or line formation, just adjusting to the 2 nearest is enough.