Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Make missiles not collide unless z is similar #52
Our Collision System currently lets Thangs with collision category
Collision detection in CodeCombat is handled by Box2D, which as one might guess only does collisions in two dimensions--the x- and y-dimensions. CodeCombat wants just about all of the gameplay logic to stay two-dimensional, since for most programming environments, it just makes more sense and it is simpler for gameplay. Our graphics are 2.5D to make things look better. Our positions and shapes are actually 3D, but in most cases we don't determine behavior from the z-dimension.
I think in this case we should, since when there's a rain of missiles, they all bounce off of each other whenever their shadows would touch. If two Thangs are firing at each other at nearly the same time, then this always happens, and sometimes they can never kill each other! It's kind of funny if two identical units are shooting each other's arrows out of the air by firing at the same instant and angle and speed, but if an Arrow Tower is going up against a Fangrider, those trajectories are totally different and shouldn't result in a collision.
Since Box2D can't natively handle z, we'll have to reach in and use its ContactListener PreSolve to stop the collision if the z distances don't touch. I hope this will work. Perhaps if not, we can resort to another more clever or more hacky way to do it.
We would modify the Collision System from within the level editor, and perhaps work with or look at the
I just set the ground_and_air_humans and ground_and_air_ogres collision categories to not collide with each other in the Collision System and Component. I want them to collide with each other, but to dynamically check and cancel certain collisions in the collision contact listener.