Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

[GM7] Curved homing attack - SA2 style


justin123

Recommended Posts

I'm trying to make a homing attack that looks like the one from Sonic Adventure 2, but I need help to figure out how to change the angle based on the distance from Sonic to the target.

Lets say the distance from the target is 200 pixels and the target is ahead of Sonic. How do I make the angle go from 180 to 0 as sonic comes in contact with the target?

Link to comment
Share on other sites

I'm assuming you already have a basic homing attack written. So, make code along these lines?

If (Homing Attack mode) is true{
         If Sonic collides with Enemy{
                     Sonic.Xvelocity = -Sonic.Xvelocity
                     Homing Attack mode = false
         }
}

That'll make Sonic go in the opposite direction.

Link to comment
Share on other sites

I'm assuming you already have a basic homing attack written. So, make code along these lines?

If (Homing Attack mode) is true{
         If Sonic collides with Enemy{
                     Sonic.Xvelocity = -Sonic.Xvelocity
                     Homing Attack mode = false
         }
}

That'll make Sonic go in the opposite direction.

I don't need sonic to go in the opposite direction, i'm just trying to figure out how to make him curve into his target.

Link to comment
Share on other sites

Oh, okay. Well, I imagine math and (A^2 + B^2 = C^2) would probably help you there.

IE: When Sonic is within 30 pixels or so of the enemy, start using their X distance (absolute value of Sonic's X position - Enemy's X position) and Y distance (same, but for Y), then generate an angle from that.

Or, do it the low tech way and constantly add/subtract from Sonic's X & Y position until it equals the enemy's.

Link to comment
Share on other sites

  • 3 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...