Forums

OverviewV-Play 1 SupportBoxCollider › Reply To: BoxCollider

OverviewV-Play 1 SupportBoxCollider › Reply To: BoxCollider
#6482

kitKat

Hi!

 

Finally i got it!

Here’s the code:

 var normalX = contactNormal.x;
                var normalY = contactNormal.y;

                console.debug("X: ", normalX, ", Y: ", normalY);


                if (normalX === 1) { //collision from left
                    
                    //check if same height (from the side)!
                    if (component.parent.y === parent.y) {
                        removeEntity();
                    }
                }
                else if (normalX === -1) { //collision from right
                   
                    //check if same height (from the side)!
                    if (component.parent.y === parent.y) {
                        removeEntity();
                    }
                }
                else if (normalY === 1) { //collision from above
                   
                    //check if same x-coordinates (from above)
                    if (component.parent.x === parent.x) {
                        removeEntity();
                    }
                }
                else if (normalY === -1) { //collision from under
                    
                    //check if same x-coordinates!
                    if (component.parent.x === parent.x) {
                        removeEntity();
                    }
                }

 

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support