collisions not working with one instance

0 favourites
  • 4 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hello,

    I am making a platformer with some boxes that I want to have destroyed if the player is doing a special move while falling. It seems really simple but I'm having trouble for some reason getting it to work. I have a solid box and a collision sprite positioned on top of the box. I am also using instance variables to check if the box can be destroyed:

    Player: on collision with Box Collision Sprite and Box collision sprite variable is 0, player is falling, and player animation down attack is playing, add 1 to box collision sprite variable.

    In another event:

    Box collision sprite variable equals 1, Box set animation 2. Animation 2 is of the box is exploding.

    In another event: Box on animation 2 finished set solid disabled and destroy the Box and the Box collision sprite.

    Comparing Y doesn't seem to do anything as well. When I preview the project the code works in a way, the animation plays but all of the boxes get destroyed when I just do the attack on one box. What am I doing wrong, or is this a bug? Thanks!

  • It's because the collision sprite doesn't relate to the box, placing it near it is not enough to relate them in events. There are ways you can do it but the most useful is probably by putting the collision sprite and box in a 'Container' (check manual).

    When in a container, when you pick a collision sprite like when the player collides with it, when you also reference the box it will know which box to pick as they are in a container together. They are also created together so when you create the box, collision sprite will be created with it and they related. You can set the position of collision sprite using image point on the box. They are also destroyed together, destroying one will destroy them both.

  • Okay, I'll give it a try! Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks So much ! It works Great!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)