AddCentralForce

From MaratisWiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "Add a force than an object. Make sure Physics and the mass of the object is enabled in the object proprieties, otherwise it won't move. Example 1 : Simple usage object =...")
 
m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Add a force than an object. Make sure Physics and the mass of the object is enabled in the object proprieties,
+
{{lua-function|addCentralForce|object, vector, local}}
otherwise it won't move.
+
  
Example 1 : Simple usage
+
Add a force than an object. Make sure Physics and the mass of the object is enabled in the object proprieties, otherwise it won't move. 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:''' Simple usage.
  
 
     object = getObject("object")  
 
     object = getObject("object")  
Line 9: Line 14:
 
     end
 
     end
  
Example 2 : Use a variable to determinate the force
+
'''Example 2:''' Use a variable to determinate the force.
  
 
     object = getObject("object")  
 
     object = getObject("object")  
Line 16: Line 21:
 
         addCentralForce(object, {power, 0, 0}, "local")
 
         addCentralForce(object, {power, 0, 0}, "local")
 
     end
 
     end
 +
 +
[[Category:Lua scripting]]
 +
[[Category:Lua function]]
 +
[[Category:Physics]]

Latest revision as of 01:26, 9 February 2014

addCentralForce(object, vector, local)

Add a force than an object. Make sure Physics and the mass of the object is enabled in the object proprieties, otherwise it won't move. 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: Simple usage.

   object = getObject("object") 
   function onSceneUpdate()
       addCentralForce(object, {1, 0, 0}, "local")
   end

Example 2: Use a variable to determinate the force.

   object = getObject("object") 
   power = 1
   function onSceneUpdate()
       addCentralForce(object, {power, 0, 0}, "local")
   end
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox