Making a sprite collision box only damage the sprite its connected to instead of every sprite

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Step into the legendary boxing ring in Boxing Legends! Master your reflexes, aim for the highest score.
  • So I've been working on enemy AI and all of its annoying intricacies these past few days for a streets of rage styled coursework project, i've managed to get their pathfinding system working but wanted to change up their hitboxes.

    The enemy sprites themselves are solid objects, and originally their hitboxes were the same size as them which resulted in it being a bit janky.

    So instead I opted to do something else, where the enemies actual collision hitbox is very small and instead they have another bigger sprite pinned to them which is essentially the thing that the player needs to hit to be able to damage the enemy.

    Now once the enemy is spawned in, these hitboxes are spawned with them and pinned to them. But the problem I'm facing is when the enemy is hit by the player, if there are multiple enemies spawned in all with the same duplicate of the hitbox pinned to them then they all get damaged which obviously isn't very helpful.

    I did try flip the hitboxes, so instead the sprite created one is pinned to the middle of the enemy. But have been having some problems considering the pinned sprite is solid and i have no clue how to properly do solid filtering.

    But it feels that there is a better way to make this work so i was wondering if it would be possible that when pinned to the enemies, the sprite boxes essentially act like an instance variable would, only corresponding to that particular element of the sprite. But again, i have no idea, so some help would be greatly appreciated.

    Cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need to pick the right enemy instance, which is pinned to the collision box.

    The easiest solution is to add both objects to the same container. They will be logically connected and will be picked automatically.

    construct.net/en/make-games/manuals/construct-3/project-primitives/objects/containers

    You should also use the hierarchy feature instead of the Pin behavior. Then you will be able to use "Pick child/parent" conditions to easily pick objects in the hierarchy. For example:

    Bullet on collision with EnemyCollisionBox
    EnemyCollisionBox pick parent Enemy : Enemy subtract 1 from health
    
  • Ahh okay! i knew it'd maybe be something like that! Thank you so much, it works perfectly now

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