vectorToAngle explanation

bjoerdaubitbjoerdaubit Member Posts: 12
edited November -1 in Working with GS (Mac)
Hello folks,

I am new to game salad and am just starting to prototype my first game. The first border I try to cross is the vectorToAngle function. Can someone explain more in depth how this function works? I don't want to know like "copy and paste vectorToAngle(x-x',y-y') and then it works" I want to know how the expression actually works.. the mathematics behind it. I generally understand what it does, but I don't understand how it is done. Especially the offset thingy.
Thanks for your time and your help! I will appreciate it a lot!!

greets
bjoern

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    vector to angle is used to find the angle between to actors or positions. So say you had one actor then you had another actor above and to the right of it. You can use vector to angle to find the angle of trajectory between them to fire a bullet at it or move to it along the exact angle and stuff like that. You first specify the 2 different actors x positions (thats the first part of the expression x-x) then there y positions (2nd part)

    So vectorToAngle(actor1.self.position.x-actor2.self.posotion.x,actor1.self.position.y-actor2.self.position.y)

    Another example is if you wanted actor1 to shoot at the mouse cursor position you can do this

    vectorToAngle(actor1.self.position.x - mouse.position.x, actor1.self.position.y - mouse.postion.y)
  • calvin9403calvin9403 Member Posts: 3,186
  • wormilwormil Member Posts: 127
    http://hyperphysics.phy-astr.gsu.edu/hbase/vect.html

    I believe this is the droids you are looking for...
  • wormilwormil Member Posts: 127
    To make it a little easier to understand this and magnitude, i've crafted you a small demo:

    Vector Magnitude

    Drag the non text actor around and notice the magnitude as you get closer and further.
    Watch the angle as well.
  • bjoerdaubitbjoerdaubit Member Posts: 12
    Hey guys,

    thanks a lot for your help! I think I got it now :D
    Great support wormil!! *cheering*
Sign In or Register to comment.