Sorry for asking a broad question, I am relatively new to defold and, despite researching for hours, I cannot figure out how to implement collisions in my top down 2d game. All the content I have come across has been based on platformer games and involve gravity, and my very limited knowledge on defold does not allow me to adapt the code.
So, I have a top down view 2d game. I have a player object, and I would like to make a program/system where, if the player collides with a wall or game prop, it cannot move through it.
I’m not necessarily asking for code, but I was wondering if there were necessary steps I must take to allow me to program this.
The collision resolution for a platformer game and a top-down game is basically the same. When you detect one or more points of collision you separate the objects using the same algorithm:
You also have a simple example here with a more naive approach to collision resolution:
Thanks for the resources! The code behing collisions makes much more sense now.
Although now, I am having trouble understanding where to place collision objects etc. Am I right in thinking a collision object goes into both the player and tilemap layer?