Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GLTFPhysicsBody

继承: Resource < RefCounted < Object

代表 GLTF 物理体。

描述

代表 OMI_physics_body GLTF 扩展中定义的物理体。这个类是 GLTF 数据与 Godot 节点的中介,并且经过了抽象,支持将来加入各种 GLTF 物理扩展。

教程

属性

Vector3

angular_velocity

Vector3(0, 0, 0)

String

body_type

"static"

Vector3

center_of_mass

Vector3(0, 0, 0)

Basis

inertia_tensor

Basis(0, 0, 0, 0, 0, 0, 0, 0, 0)

Vector3

linear_velocity

Vector3(0, 0, 0)

float

mass

1.0

方法

GLTFPhysicsBody

from_dictionary ( Dictionary dictionary ) static

GLTFPhysicsBody

from_node ( CollisionObject3D body_node ) static

Dictionary

to_dictionary ( ) const

CollisionObject3D

to_node ( ) const


属性说明

Vector3 angular_velocity = Vector3(0, 0, 0)

  • void set_angular_velocity ( Vector3 value )

  • Vector3 get_angular_velocity ( )

该物理体的角速度,单位为弧度每秒。仅在物体类型为“rigid”或“vehicle”时使用。


String body_type = "static"

  • void set_body_type ( String value )

  • String get_body_type ( )

该物体的类型。导入时,控制 Godot 应该生成何种类型的 CollisionObject3D 节点。有效值有“static”“kinematic”“character”“rigid”“vehicle”“trigger”。


Vector3 center_of_mass = Vector3(0, 0, 0)

  • void set_center_of_mass ( Vector3 value )

  • Vector3 get_center_of_mass ( )

该物体的质心,单位为米。使用相对于物体的局部空间。质心默认为物体的原点。


Basis inertia_tensor = Basis(0, 0, 0, 0, 0, 0, 0, 0, 0)

  • void set_inertia_tensor ( Basis value )

  • Basis get_inertia_tensor ( )

该物理体的惯性张量,单位为千克平方米(kg⋅m²)。仅在物体类型为“rigid”或“vehicle”时使用。

转换为 Godot RigidBody3D 节点时,如果该值为零,则会自动计算惯性。


Vector3 linear_velocity = Vector3(0, 0, 0)

  • void set_linear_velocity ( Vector3 value )

  • Vector3 get_linear_velocity ( )

该物理体的线速度,单位为米每秒。仅在物体类型为“rigid”或“vehicle”时使用。


float mass = 1.0

  • void set_mass ( float value )

  • float get_mass ( )

该物理体的质量,单位为千克。仅在物体类型为“rigid”或“vehicle”时使用。


方法说明

GLTFPhysicsBody from_dictionary ( Dictionary dictionary ) static

通过解析给定的 Dictionary 新建 GLTFPhysicsBody 实例。


GLTFPhysicsBody from_node ( CollisionObject3D body_node ) static

从给定的 Godot CollisionObject3D 节点新建 GLTFPhysicsBody 实例。


Dictionary to_dictionary ( ) const

将这个 GLTFPhysicsBody 实例序列化为 Dictionary


CollisionObject3D to_node ( ) const

将这个 GLTFPhysicsBody 实例转换为 Godot CollisionObject3D 节点。