#How to create hit VFX in overlapping parts between hurtbox and hitbox?

9 messages · Page 1 of 1 (latest)

charred cobalt
#

Hello discord, is there a way to tell the engine where to create a hit VFX between 2 overlapping collision boxes? I made a quick sketch, and ideally, it would pinpoint a coordinate in the center of the overlap, such as where the x is in said sketch.

Previously, I've been instancing the hit VFX on the center of the enemy hit, and while it works fine, I want to make a more accurate system, but I'm not sure where to start. I was thinking about fiddling with bbox functions, but i want it to work regardless of where it overlaps.

To find such a method that can always pinpoint the center point between overlaps of potentially various sizes, that is what I am looking for. Would any of you know of a way? Thank you!

gilded flint
#

there is no built in function, but you can calculate it with math.

like, every object has variables
bbox_left bbox_right the x of the far left and right of the mask
bbox_top bbox_bottom the y of the far top and bottom of the mask

you can use these to calculate the middle of the overlap

#

you can do something like

(green obj's BB_L - Blue object's BB_R)/2
to get the middle of the overlap
then add it to the green's BB_L or subtract from the blue's BB_R

and prob something similar for the vertical.

#

or maybe for vertical get the center point of each object and do this math, instead of the bbox.

#

@charred cobalt

charred cobalt
#

late reply but tyvm this'll do the trick

#

i thought it would be an issue that it would only consider 1 side of an interaction but this should work regardless of whether its been hit from left to right or right to left

gilded flint
#

@charred cobalt you can prob do a check for if the touching object's x > x or x < x for deciding what sides to check

charred cobalt
#

Wouldnt it work regardless of which side? Maybe not but from what i think it should work like that?