Difference between revisions of "IsWithinDist"
From scripting
(Created page with " global proc int IsWithinDist(string $Obj1, string $Obj2, float $Dist) { //Author Nick Pisca 0001d 2009 float $B1[] = `getAttr($Obj1+".translate")`; vector $B1Vec...") |
(No difference)
|
Latest revision as of 07:05, 22 April 2017
global proc int IsWithinDist(string $Obj1, string $Obj2, float $Dist) { //Author Nick Pisca 0001d 2009 float $B1[] = `getAttr($Obj1+".translate")`; vector $B1Vec = <<$B1[0], $B1[1], $B1[2]>>; float $B2[] = `getAttr($Obj2+".translate")`; vector $B2Vec = <<$B2[0], $B2[1], $B2[2]>>; vector $BDiff = $B1Vec - $B2Vec; float $BDist = mag($BDiff); int $Win = 0; if ($BDist <= $Dist) { $Win = 1; } return $Win; }
More information on vector declarations and calculations, read pages 12-15 in YSYT.