Bind specific component to property

I have a node called LeftSideBumper, which has a custom script that should only perform some action when another object collides with a specific collider.

Therefore, in TypeScript, I added a property to specify the collider to look for:

@property(cc.PhysicsCollider)
sideCollider: cc.PhysicsCollider = null;

Now I expected to be able to bind one of the LeftSideBumper node’s many colliders to the sideCollider property, like I could in e.g. Unity.
However, it seems like I can only bind the whole Node to the property:
38
I’m moving over from Unity, so please let me know if this is not the way things are done in Cocos Creator.

In the meantime, I’ve found a workaround/solution using collider tags, but I still want to know whether it’s possible to bind a specific component to a property instead of just the whole node, which may contain multiple of the component.

Thanks in advance,
Marius

it’s possible to hack it directly in the prefab or scene (.fire), by changing the id of the PhysicsCollider component, but i guess that’s a bit too hackish.

one would expect, when using the node tree tools (as exemplified here: https://docs.cocos2d-x.org/creator/manual/en/getting-started/basics/editor-panels/node-tree.html) to select the search type “Component” and receive a list of the actual components (not the nodes containing the component). but, alas, it doesn’t work like this.

let’s hope maybe a dev catches a glimpse of this and addresses it in the future versions.

1 Like

Yeah, besides the lack of documentation, this is probably the only major drawback to Unity I’ve discovered so far.