Destroy Hit Detection Box

0 favourites
  • 8 posts
From the Asset Store
Detects any kind of ad blocker. Very easy implementation into already existing projects
  • Hey there,

    When i make the player attack, it spawns a hit detection box in front of him, at a certain frame. When the attack animation is over, i used the command destroy object on the box. Now this seem to work pretty well. Now i did the same with an enemy. They got their own hit detection box, it spawns just fine, but when it comes to destroy the box after the animation, it just fails.

    Is there anything i'm missing about destroying an object? Why is it working on one character but not on the other?

    Greetings

    PP

  • Without seeing the events it is not easy to answer..

    First thing that comes to mind is there are more enemies than one and one of them is still playing the animation..

    But like I said, without events and/or capx it's hard to say..

  • Oh you are right, here you go.

    The whole event is nested inside a "for each enemy" event. So that may be the problem?

  • The image isn't showing.

    I suspect that you're not picking the right box instance that is "paired" with the specific enemy instance. It works for the player probably because there's only one player object and one player-box object.

  • Working now?

    immortalx It's definitely the right box, i coloured player and enemy detection in different colours for testing and they both show up and the player box also got destroyed, just the enemy box seems to stay there, till the enemy attacks again, creating another box.

    Thanks for your answer!

  • Well, you don't reference the enemy attack box in the event so there is no way for the program to know which instance of it you mean, for it is in no way related to the enemy that it is spawned by..

    You are creating attack boxes every tick while frame 5 and 6 are playing, but you are also creating attack boxes while frame 7 is playing and destroying them, but a created object can't be referenced untill the next top level event..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LittleStain has a better understanding and explained it way better than me. Maybe you could try to store the IID of the box in a variable, right after its creation.

    Then, on the "Animation frame>=7" event insert a subevent "Pick Nth instance" where N=the previously stored IID and destroy the object there.

  • Okay thank you guys, i think i understand a bit better now how construct reads the events. Gonna test it soon.

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