Finding vectorToAngle opposite

toucansamuraitoucansamurai Member Posts: 4
edited November -1 in Working with GS (Mac)
This seems like it should be simple but it's driving me nuts. I worked for a while to get a vectorToAngle formula that allowed an actor to fire bullets at the mouse cursor, and eventually used this one (http://gamesalad.com/forums/topic.php?id=8090) plus the camera offset that works great. It's basically:

vectorToAngle( self.MouseX - self.Position.X + game.camX , self.MouseY - self.Position.Y + game.camY )

Problem is, I'm now trying to set up a mode that fires bullets in the complete opposite direction (directly away from the mouse), and while I remember setting up that way back when I was playing around with the formula before, I can't seem to get it again.

I've tried going negative vectorToAngle, subtracting and adding 180 from the angle, switching the (mouse-position) parts of the formula (that seemed most likely -- I'd want to create a vector from mouse to the actor, no?), and even adding instead of subtracting the camera offset. Nothing I do will send a bullet in that opposite direction. Math guys, what am I doing wrong?

Comments

  • toucansamuraitoucansamurai Member Posts: 4
    Huh. Well it turns out I had a few things going on here, some of which had nothing to do with this issue. But in the end, the solution I came up with was putting a negative velocity on the bullet, essentially just keeping the same angle, but sending it the wrong way. Works great.

    I'm sure there's a math-y way to get the opposite vector to angle, but a negative velocity seems to work just as well. Thanks anyway! Going to leave the topic here for anyone who might need it in the future.
Sign In or Register to comment.