Created
July 30, 2014 09:56
-
-
Save error454/478fe33f77533347bc84 to your computer and use it in GitHub Desktop.
Basic Vectors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ex,ey,ez = object.getTranslation ( hEnemy,object.kGlobalSpace ) | |
local ox,oy,oz = object.getTranslation ( o,object.kGlobalSpace ) | |
-- vector pointing at the enemy | |
local dx,dy,dz = math.vectorSubtract ( ex,ey,ez,ox,oy,oz ) | |
-- distance between enemy and object | |
local dist = math.vectorLength ( dx,dy,dz ) | |
-- vector pointing at enemy with length of half the distance | |
local fx,fy,fz = math.vectorSetLength ( dx,dy,dz, dist * 0.5 ) | |
-- Coordinate starting at the character going dist * 0.5 towards enemy | |
local x,y,z = math.vectorAdd ( ox,oy,oz,fx,fy,fz ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment