This 2D physic system is a sub system of the engine project I've worked on since the beginning of the Fall 2020 semester.
The system will contain functions and features mainly from two parts, 2D collision checking and 2D motion.
Collision checking for rectangular and circular shaped colliders.
Nonblocking trigger type overlapping checking for rectangular and circular shaped colliders.
Layering collision checking with three different layers -- non-colliding, overlapping, blocking.
Non-colliding objects won't be checked for collision with any other objects.
Overlapping objects can be used as triggers. Overlapping colliders are non-blocking. An OnTriggerEnter event will be generated for an overlapping collider when a blocking collider or another overlapping collider enters its area.
Blocking objects will block other blocking objects when they bump into each other. An OnCollision event will be generated when for a blocking collider when it is hit by another blocking collider.
Adding/setting linear force to a game object.
Adding/setting linear velocity to a game object.
Adding linear impulse to a game object.
Adding/setting angular velocity to a game object.
Adding angular impulse to a game object.
Setting the mass of a game object.
Moving objects in the scene according their velocity.
Adjusting objects' velocity from collision.
There will be a collider class and a rigid body class used to store information for colliders and rigid bodies (e.g. Shape information for colliders, velocity and mass for rigid bodies). Prefabricated collider and rigid body data will be stored in a human-readable format with a syntax fashion same as Lua tables.
Users can call public getter or setter functions from the collider class and the rigid body class to get or change property values of instances.
Users can override OnTriggerEnter() and OnCollision() functions in their customized game object class to defined the behavior of an object when collision occurs.
A RigidBody class that stores motion data and updates the position and rotation of game objects.
A Collider class that stores the size, shape and collision layer of a collider and handles collision checking.
Collision callback functions for game objects.
A ColliderBuilder project to convert human-readable collider data to binary.
A RigidBodyBuilder project to convert human-readable rigid body data to binary.
Adding more features to the collision call back functions (e.g. Add OnCollisionStay(), OnTriggerStay(), OnTriggerExit() functions).
Adding support for single-sided edge colliders.
Adding support for custom-shaped colliders.