Hi there, this question is very interesting, it’s basic but not easy. Let me head straight forward to an answer: don’t use the builtin physics engine or the collision system in Cocos, try GitHub - Sinova/Collisions: Collision detection for circles, polygons, and points if you want to have an in depth understanding of the topic.
How good is that solution? For multiplayer action game use I ported the algorithm into Golang and then transpiled it along with other game dynamics back to js for the frontend, and the result is like [Video attached] Rollback Netcode on websocket with a Multiplayer Platformer game demo open sourced – you can manage all “hard pushbacks” and “soft pushbacks” flexibly – which is nearly impossible with a builtin physics engine. Good luck coding!