Translate
From MaratisWiki
(Difference between revisions)
(Created page with "Simply Translate the object in 3d space, the 3 zeros are X,Y,Z values. Example 1 Continuous translation : object = getObject("object") -- Scene update function ...") |
Dahnielson (Talk | contribs) m |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{lua-function|translate|object, vector, local}} | |
− | Example 1 Continuous translation | + | Translate the object in 3d space, the 3 zeros are X,Y,Z values. The "local" argument is optional (local coordinates), without it the transformation is global (global coordinates). |
+ | |||
+ | {{lua-function-param|object|object to operate on}} | ||
+ | {{lua-function-param|vector|vector}} | ||
+ | {{lua-function-param|local|local}} | ||
+ | |||
+ | '''Example 1:''' Continuous translation. | ||
object = getObject("object") | object = getObject("object") | ||
Line 9: | Line 15: | ||
end | end | ||
− | Example 2 : Translate on key press | + | '''Example 2:''' Translate on key press. |
object = getObject("object") | object = getObject("object") | ||
Line 16: | Line 22: | ||
if isKeyPressed("SPACE") then translate(object, {0, 0, 1}, "local") end | if isKeyPressed("SPACE") then translate(object, {0, 0, 1}, "local") end | ||
end | end | ||
+ | |||
+ | [[Category:Lua scripting]] | ||
+ | [[Category:Lua function]] | ||
+ | [[Category:Transformation]] |
Latest revision as of 00:17, 9 February 2014
translate(object, vector, local)
Translate the object in 3d space, the 3 zeros are X,Y,Z values. The "local" argument is optional (local coordinates), without it the transformation is global (global coordinates).
-
object
: object to operate on -
vector
: vector -
local
: local
Example 1: Continuous translation.
object = getObject("object") -- Scene update function onSceneUpdate() translate(object, {0, 0, 1}, "local") end
Example 2: Translate on key press.
object = getObject("object") -- Scene update function onSceneUpdate() if isKeyPressed("SPACE") then translate(object, {0, 0, 1}, "local") end end