How do I create blood explore on the overlap area ?

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi there, I would like to ask if the Player slash the enemy, the blood will explore on the position where the Slash FX overlaps with the Enemy sprite. ( I already have the blood sprite, I would only ask how can I get the position/area where the object A overlap object B) Thank you very much ^^

  • How exact do you intend it to be? Getting the exact overlapping area would be pretty tough. The most simple solution would be to just let it splash from the enemy that was hit with enemy.X enemy.Y.

    A different solution I sometimes use is to add an image point to the slash and one in the center of the enemy. Then get the average of their positions. (enemy.ImagePointX + slash.ImagePointX)*0.5. So if you hit it closer to the head the blood will also splash from closer to the head. Might not always be perfect but I think it generally works fine in most cases.

  • Hi, thank you WakyTaoaster ^^. I have thought about that solution(enemy.ImagePointX + slash.ImagePointX)*0.5), but for some big/giant boss if I slash to the leg under the knee, the blood might appear somewhere above the knee.

    I am thinking about the rectangle collision polygon that contains FX Slash sprite and Enemy sprite. If I can get the position of these vertexes of the rectangle, I can find the intersection of the edges and find out the overlapping area. I don't know for sure if it's possible but will try ^^.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your blood sprite should be spawned based on your sword's position rather than the boss. To be more accurate, you can pin multiple invisible helper sprites along the hitbox of the sword. Upon a hit, pick all the helper sprites that are overlapping the boss, and then pick the nearest one to the player, and use that position to spawn your blood animation.

  • Wow! amazing idea, thank you very much!

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