However, how can I use tag for colliding objects? The tag that’s in the box collider component? Or is it possible? Would appreciate any help…Thanks and God Bless…
Thanks for the example, really appreciated it…But what I’m trying to accomplish is to use the tag behavior to differentiate between objects / node that come in contact… Can I use a combination of tag with cc.recIntersectsRect for colliding objects, like below:
Which is essentially prefabs / objects that can collide with the main node, being leftzombie. So, I’m trying to make the collision just collide with specified objects as per collider tag, not with every object in the scene…Thanks again for help and God Bless…
Thanks for the quick explanation, much appreciation…
Yes, I’ve set up already the collider groups and assigned them individually to their groups within their nodes.…However, let’s say, I have a collider group by the name of zombies, then I have a wall and I have a lightning, so I’ve checked under Group Collide Map - > zombies - > wall - > lightning… In other words, zombies should collide with wall and lightning as per checked…So far so good…Nevertheless, when I apply the simple method of colliding using getBoundingBox like above without the tag… When zombies hit the wall, is fine, but within the zombie node, I also have a methodcollider set for Lightning, which is only supposed to fire when zombies collide with lightning and not wall…I hope you understand… Thanks again for the help…God Bless…
onCollisionEnter:function(other,self){
this.node.color = cc.Color.RED;
this.touchingNumber ++;
//Left Zombie Collides with Left Bullet–Function//
if(cc.rectIntersectsRect(this.node.getBoundingBox(),this.zombiecolliderobjects[0]))
{this.ZombieBulletLeftHit()}
//Left Zombie Collides with Right Bullet–Function//
if(cc.rectIntersectsRect(this.node.getBoundingBox(),this.zombiecolliderobjects[1]))
{this.ZombieBulletLeftHit()}
//Left Zombie Collides with U Lightning–Function//
if(cc.rectIntersectsRect(this.node.getBoundingBox(),this.zombiecolliderobjects[2]))
{this.ZombieLightningHitBurn()}
//Left Zombie Collides with The U Tornado --Function
if(cc.rectIntersectsRect(this.node.getBoundingBox(),this.zombiecolliderobjects[3]))
{this.ZombieLightningHitBurn()}
I’ve set up the Group Colliders via the panel and within each node ( group ), placed checked marks for collision within the panel, and added the above code… So, the issue that I’m having is that example, if this.node (zombie ) collides with this.zombiecolliderobjects[0] ( bullet ) it’s supposed to call method {this.ZombieBulletLeftHit()} , but it doesn’t, it calls method {this.ZombieLightningHitBurn()}. I added else at the end of each if to see if it would solve the issue, but it didn’t work…Would appreciate any feedback…Thanks and God Bless…
Taking a break from working on Unity, going back to Cocos Creator, for those newbies in Cocos Creator, regarding Colliding different nodes / objects and invoking their respective methods, I found a solution:
onCollisionEnter:function**(other,self)**{
this.node.color = cc.Color.RED;
this.touchingNumber ++;
//Collides with Bullet Left- Destroy Zombie Function //
if(other.node.name==“bulletprefableft”)
{this.ZombieBulletLeftHit()}
So, instead of using Tag, which I don’t know, if it could be use, I used the name of the node to differentiate the methods invoking (ex: player hits bullet, player eats food, etc…) . Hopefully this can help any newbie entering into using Cocos Creator…Thanks and God Bless…