[SOLVED] How to use Cocos Creator Collider Component

Hi,

So in the latest version of Cocos Creator they added Collider Component but are there any documentation on it? It would be great if this can get update here: http://www.cocos2d-x.org/docs/editors_and_tools/creator/#components and have a Collider section.

Or are there any demo games that showcase how to use the Collider Component?

That would be great. Thanks in advance!

http://www.cocos.com/docs/creator/physics/index.html

Thank you and thank Google for translating websites to english.

Thanks!

hehe google is your friend… :smile:

1 Like

Actually @eydamson I’m still having trouble getting collision to work in my project. I am trying to follow the examples in https://github.com/cocos-creator/example-cases/tree/master/assets/cases/collider

I don’t know what I’m doing wrong but I do feel like I am missing a step. Here is what I did:

  1. Added Collider Component to my wall/platform (tag: 0)
  2. Added Collider Component to my player (tag: 1)
  3. Project -> Project Settings -> Created a group for wall and group for player and checked the box for their collision together
  4. Where do I put the onEnable code and onCollisionEnter from the git examples?
  5. How is groups connected to the nodes/tags in any way inside Creator?

Thanks!

i havent tried it yet but i believe you should put that script in the node that has the collider…

and tags are just tags no biggie to it…
but the important part is the collision group… only the nodes that has the checkbox mark on it can collide with each other.

how do i know? its basically just like unity3d’s Physics system :smile:

Thanks for the quick reply but I’m still a little confused. Thanks for bearing with me.

Ok let’s say I have a wall node with a background script and a player node with a player script. So which script does the collider code go into for these 2 nodes to register a collision?

And how would I associate a group number to these nodes?

Sorry for sounding like a total newbie/beginner. I could research it more but if you know then it would save me a lot of time haha.

UPDATE:
Nvm got it!
In the Node Properties you set the group there (The documentation didn’t say this so I didn’t catch it before) and I put the enable collision code in the play script.

2 Likes