浏览代码

Added physics.set_shape()

Björn Ritzl 1 年之前
父节点
当前提交
ab2f8ed81e
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      docs/en/manuals/physics-shapes.md

+ 22 - 0
docs/en/manuals/physics-shapes.md

@@ -96,6 +96,28 @@ The above example defines the four corners of a rectangle:
 The collision object and its shapes inherit the scale of the game object. To disable this behaviour uncheck the [Allow Dynamic Transforms](/manuals/project-settings/#allow-dynamic-transforms) checkbox in the Physics section of *game.project*. Note that only uniform scaling is supported and that the smallest scale value will be used if the scale isn't uniform.
 The collision object and its shapes inherit the scale of the game object. To disable this behaviour uncheck the [Allow Dynamic Transforms](/manuals/project-settings/#allow-dynamic-transforms) checkbox in the Physics section of *game.project*. Note that only uniform scaling is supported and that the smallest scale value will be used if the scale isn't uniform.
 
 
 
 
+# Resizing collision shapes
+The shapes of a collision object can be resized at runtime using `physics.set_shape()`. Example:
+
+```lua
+-- set capsule shape data
+local data = {}
+data.diameter = 10
+data.height = 20
+physics.set_shape("#collisionobject", "my_capsule_shape", data)
+
+-- set sphere shape data
+data = {}
+data.diameter = 10
+physics.set_shape("#collisionobject", "my_sphere_shape", data)
+
+-- set box shape data
+data = {}
+data.dimensions = vmath.vector3(10, 10, 5)
+physics.set_shape("#collisionobject", "my_box_shape", data)
+```
+
+
 # Rotating collision shapes
 # Rotating collision shapes
 
 
 ## Rotating collision shapes in 3D physics
 ## Rotating collision shapes in 3D physics