@luke2125 wrote:
Hi,
I have some If Else statements to detect colliding with my prefabs, but the issue that I'm having is that there's no differentiation, let me explain as an example:
1) Zombie collides with Bullet - > Invoke Zombie Destroy Method
2) Zombie collides with Rock - > Invoke Zombie Ash BurnNow, what I'm getting is that it executes # 2, when it collides with # 1 , now I've tried different variations using the If Else, with else if, else, etc..... and still stuck. So, I thought about using switch statement, since it has a break mechanism, but having difficulty setting up, please see below for my code:
//Left Zombie Collides with Left Bullet--Function//
// if(cc.rectIntersectsRect(this.node.getBoundingBox(),this.zombiecolliderobjects[0]))
// {this.ZombieBulletLeftHit()}**
//Left Zombie Collides with Rock//
// if(cc.rectIntersectsRect(this.node.getBoundingBox(),this.zombiecolliderobjects[3]))
// {this.ZombieLightningHitBurn()}Now, like mentioned above, when the above gets executed zombie collides with Bullet, it goes to execute this.ZombieLightningHitBurn, which is not correct. I've set up the ****whole group manager **** along with each individual node's group collider, drop-down as well....So, I'm also thinking, maybe I also need the tag from the collider component, but I've tried different variations with the tag to differentiate between objects.... and still nothing, so now I'm into using switch like below:
var count = [0,1]
switch(cc.rectIntersectsRect(this.node.getBoundingBox())){
case count 0:this.zombiecolliderobjects[0];
this.ZombieBulletLeftHit();
break;
case count 1:this.zombiecolliderobjects[0];
break;Any help, guidance or information, will be greatly appreciated it.....Thanks for your time and God Bless.....
Sincerely,
Sunday
Posts: 2
Participants: 2