I am trying to set up a collision system for a tilemap in my component based entity system, but having trouble with figuring out how to do so.
Currently I have the following approach: My tilemap consists of a Tilemap_Component, which just holds the array, a Tilemap_Render_Component, which holds the Tileset image, and a Tilemap_Collision_Component, which holds the information which tile value is handled as a wall.
To make an entity collideable with the tilemap it needs currently the following components: Movement_Component, which holds the X/Y Velocity, Position_Component, which holds X/Y Position and Tilemap_Collider_Component, which holds the information if the object only collides with walls or as well with some other objects in the tilemap.
Now my problem is the following: It is very hard to determine what to do with an object which collides with the tilemap. If I set velocity to zero, it is possible to glitch through walls because Movement and Input are handled in other systems than the collisions. If I just change the Position of the object, there occur two problems: One is, that the object starts to flicker because it has moved a bit. The other is, that I would have to know how big the object is which is colliding with the wall. Now I could just say that a Render_Component is required for objects which can collide with the tilemap and then use the image information in the Render_Component of the object and the Tilemap_Render_Component of the tilemap to calculate collision, but I think this is a bit against the intention of component based system.
What would be your suggestions? How could I handle this problem? Or, as well: Was anyone of you faced to such a problem? How did you solve it?