YesNoOk
avatar

Collision detection with diagonal lines? (Read 272 times)

Started by FastFlash, November 24, 2019, 03:32:01 am
Share this topic:
Collision detection with diagonal lines?
#1  November 24, 2019, 03:32:01 am
  • ***
    • Portugal


The front of the beam is a separate helper that moves diagonally; when the enemy gets between it and the player (so if the enemy touches that diagonal blue trail), I want to spawn a helper that hits him away. The blue trail is an explod that is rotated and scaled according to distance. (Using mugen 1.1)

Problem is, I just cant seem to correctly define the "hitting area".



I managed to do it correctly with the horizontal version of the move, by using this set of triggers to spawn in the helper:

Code:
trigger1 = enemy, pos x < pos x
trigger1 = enemy, pos x > root, pos x
trigger1 = enemy, pos y > pos y-3
trigger1 = enemy, pos y < pos y+40

I tried modifying the triggers for the diagonal version but I can't get it to work right. I tried this:

Code:
trigger1 = enemy, pos x < pos x
trigger1 = enemy, pos x > root, pos x
trigger1 = enemy, pos y < (root,pos Y - enemy, pos x)
trigger1 = enemy, pos y >= pos y

But it results in the enemy getting hit before he touches the beam trail, and I can't seem to modify it to properly "cover" the area.

Help?
I like cats...
Re: Collision detection with diagonal lines?
#2  November 24, 2019, 04:05:18 am
  • ****
  • CPU Purple Heart
    • USA
    • www.dailymotion.com/2a8130871d2742d2f4da3b069

  • Online
 Since it is literally impossible to adjust hitbox direction without using completely separate animations to accommodate the possible angles that you plan to do, which would be a ton of set-up, have you looked into using the projectile sctrl spawned within the helper itself? The idea is that as long as the beam helper exists, it constantly spawns a stream of projectiles from the starting point that project towards the specific direction you want in accord to the beam angle FX itself, each projectile is invisible, but have red and blue CLSNs. The projectile velocity parameter can be adjusted with perhaps some sort of variable within the helper to determine projection angle variations.
Re: Collision detection with diagonal lines?
#3  November 24, 2019, 04:46:33 am
  • ***
    • Portugal
Since it is literally impossible to adjust hitbox direction without using completely separate animations to accommodate the possible angles that you plan to do, which would be a ton of set-up, have you looked into using the projectile sctrl spawned within the helper itself? The idea is that as long as the beam helper exists, it constantly spawns a stream of projectiles from the starting point that project towards the specific direction you want in accord to the beam angle FX itself, each projectile is invisible, but have red and blue CLSNs. The projectile velocity parameter can be adjusted with perhaps some sort of variable within the helper to determine projection angle variations.

Im not using projectiles or the hit boxes of the beam itself. I'm spawning in a helper on p2 position that hits p2 and knocks him away whenever he gets between the player and the beam "head". Problem is I can't seem to tell mugen what "between" is.

Unless you're suggesting I scrap that and just go with the projectile method? Which I'm worried won't be as accurate but I will have to if I can't get this to work
I like cats...
Re: Collision detection with diagonal lines?
#4  November 24, 2019, 05:17:10 am
  • ****
  • CPU Purple Heart
    • USA
    • www.dailymotion.com/2a8130871d2742d2f4da3b069

  • Online
 Ah, in that case, you'll probably have to do some math to consider the shape of the beam itself, but I myself wouldn't be quite sure what that exact math is. I've ran into a similar problem with Reisen's fields and their area of effect proximity, which forced me to look into another character whose uses proximity math for a circle. I would imagine you would need to do math for a tilted rectangle of some sort and even then, it's sorta sketchy even there. Best alternative I can think of is just simply spawn the helper along the trail's area as opposed to exactly on P2's area if they enter the distance between root and beam head helper.
Re: Collision detection with diagonal lines?
#5  November 24, 2019, 08:52:45 pm
  • ***
    • Portugal
Ah, in that case, you'll probably have to do some math to consider the shape of the beam itself, but I myself wouldn't be quite sure what that exact math is. I've ran into a similar problem with Reisen's fields and their area of effect proximity, which forced me to look into another character whose uses proximity math for a circle. I would imagine you would need to do math for a tilted rectangle of some sort and even then, it's sorta sketchy even there. Best alternative I can think of is just simply spawn the helper along the trail's area as opposed to exactly on P2's area if they enter the distance between root and beam head helper.

I tried that and managed to get it work; then I adapted the maths I used to my original method.

Code:
trigger1 = root, p2bodydist x < (pos x)*facing
trigger1 = root, p2bodydist x > 0
trigger1 = enemy, pos y < -(root, p2bodydist x) - 5 + root, pos y
trigger1 = enemy, pos y >= -(root, p2bodydist x) - 30 + root, pos y

Probably not the best way to do this but it works well enough. Thanks for the help  ;D
I like cats...