SetPosition

(Difference between revisions)
Jump to: navigation, search
m
Line 1: Line 1:
 +
{{lua-function|setPosition|object, vector}}
 +
 
Set an object to a given position.
 
Set an object to a given position.
  
Example 1 : This script will move an object to another object.
+
'''Example 1:''' This script will move an object to another object. <code>getPosition</code> is used to determinate the first object (the target) position.
getPosition is used to determinate the first object (the target) position.
+
  
 
     object = getObject("object")  
 
     object = getObject("object")  

Revision as of 18:43, 8 February 2014

setPosition(object, vector)

Set an object to a given position.

Example 1: This script will move an object to another object. getPosition is used to determinate the first object (the target) position.

   object = getObject("object") 
   object2 = getObject("object2")
   -- Scene update
   function onSceneUpdate()
       objectpos = getPosition(object)
       if isKeyPressed("SPACE") then setPosition(object2, {objectpos[1], objectpos[2], objectpos[3]}) end
   end
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox