How to manage Kinematic object and how to manage collisions

Hi to you all, sorry for this really basic topic:

I need to understand how to deal with a Kinematic RigidBody colliding with an object with a Static RigidBody.

I’m currently reading the documentation:
https://docs.cocos.com/creator/manual/en/physics-2d/physics-2d-contact-callback.html

The problem though is that I haven’t figured out what values I have to use to keep track of how far I have to move the object “back” so as not to leave it overlapping it.

In fact I simply have to make sure that my player (whose movement goes only to the right and left) to cross with a Wall must stop and not continue with his movement.

How should I do without having to make it Dynamic?

What version of Creator editor are you using?
Looking at your question it should be, just collision detection to make the object stop, no need to generate physics effects.

Can you refer to this demo and try using the collision detection function?

hi, thanks for the response, but i was searching about a 2d context, not 3d. The version of Cocos Creator is 3.6.3.

For now what i found is the worldManifold method that i have to call with the contact Object. But i don’t know how to manage it, there is some example or article ? :frowning:

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!

1 Like

Sorry, I misread it, it’s a 2D physics problem.
So for an example of what you need, you can refer here

1 Like

thanks for the links, but unfortunately i didn’t found an example in this github repo about kinematic body, only dynamic :frowning:

Plus, some of the main examples that we can find inside the main repo of cocos creator not work and i don’t know why because chinese messages on the screen (i suppose there is no cannon.js or bullet.js module ?)

Hi! I’ve not installed already a module inside a cocos creator project. Do you mean to install it with npm and use it within a script component? If yes, can you show me an example how to do it? This is a first attempt to use a module inside cocos creator, i’m not already 100% confident with it but i would like to try it! :smiley:

I don’t know ccc’s idiomatic way either, my way is a little curvy but generic to build the lib by webpack and port it directly into ccc project, like this DelayNoMore/frontend/assets/scripts/modules at v0.8.5 · genxium/DelayNoMore · GitHub

Official members please help here if any disagreement with my approach

I suppose this example that you shared to me is with a CC version too old (i see fire extension for the scenes). Can you explain to me a controller that you would manage?

Better ask @muxiandong or @pandamicro for help

Have you checked matrix of collision?

No, can you give me some instruction on how to manage kinematic body and to solve the collisions? :frowning:

try to check maybe there is nothing to marked

oh that one, yes. I have my elements. But what i don’t know how to work is on the callbacks. How can i intercept and calculate the collision from a static and a kinematic body?