Jump to content

Photo

Finding distance between Link & an FFC or an lweapon/eweapon


  • Please log in to reply
3 replies to this topic

#1 idontknow8

idontknow8

    Senior

  • Members

Posted 22 February 2017 - 03:09 PM

How do you script the distance between Link & an object such as a FFC or an lweapon or eweapon?

 

Is it (in non-scripting language):

 

The difference of the X positions of each, squared + the different of y positions, squared and then the square root of that?  (A^2 + B^2 = C^2)

 

So like Link->X - FFC->X, Squared + Link->Y - FFC->Y, squared, and then the square root?

 

 



#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 22 February 2017 - 03:25 PM

Yes, that's how you could go about doing it. However, we have functions that do all the work for us. Distance(Link->X, Link->X, FFC->X, FFC->Y) will do the trick. I'd assume it does everything you just outlined internally, but boy is it a lot easier to type. :P

#3 idontknow8

idontknow8

    Senior

  • Members

Posted 22 February 2017 - 05:16 PM

oh nice!  Can it also be used for lweapons?  As in:

 

(Link->X, Link->Y, lweapon->X, lweapon->Y)?  What about other pointers?



#4 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 22 February 2017 - 06:32 PM

Yeah. It can be used with just about any pointer type, or with just coordinates, like Distance(lweapon->X, lweapon->Y, 120, 80). Same goes with the Angle function, which goes hand in hand with the Distance function.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users