Most efficient way for Collision when units Attack

0 favourites
  • 6 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • Hello,

    I have some units on the layout that chase each other. Once they're close to their target, they start an attack animation. At this animation's end, I would like to damage the units that are overlapping when (invisible) attack zone of the attacker.

    What is the best way, more efficient, to do this ? Any idea ?

    I came with two way :

    • test for collision when animation end between attacker's attack zone and units from different team
    • toggle a boolean for attack zone when animation ends and test for collision in another event between toggled attack zone and units
  • You can't check for collision as collision event might happen while animation is still playing, so you need to check for overlapping.

    Something like this:

    Unit on animation "attack" ended

    Unit is overlapping Enemy -> (deal damage to the enemy)

  • I do it with:

    if animation frame = ( end frame of your animation's attack hit here ) and overlaping enemy = true

    end frame because that is usually end of hitting or stabbing motion animation, but if you have a more complex animation you'd use whatever frame the hit/stab happens at.

  • I already do the same. But what would be the best way to do this for performance ? It seems that collision tests are better placed at top level event instead of inside a sub event.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No, quite the opposite.

    If your parent event is "animation has ended", and in the sub-event you check if objects are overlapping, then overlapping check will not be performed while animation is playing. So it will have zero impact on performance.

    It's the same situation with "On collision" event, however since "On collision" is a triggered event (it only lasts for 1 tick), you should be careful when using it in sub-events.

  • dop2000, Thanks for the tip !

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