Skip to content

Rigidbody (JavaScript) ​

Rigidbody ​

Scripting Name:Insight.Rigidbody

物理刚体。

  • _在 Web _SDK__中无效

*注意:洞见__SDK_ v2.1 版本中去掉了物理引擎的支持,因此在洞见 SDK v2.1 无法使用这些接口。_

Properties ​


angularVelocity ​

type : Insight.Vector3

刚体在世界空间的角速度(单位是弧度)。

isKinematic ​

type : boolean

(只读)是否受物理影响。

mass ​

type : number

刚体的质量。

sleepThreshold ​

type : number

休眠阈值。

useGravity ​

type : boolean

是否受重力影响。

velocity ​

type : Insight.Vector3

刚体在世界空间的速度。

worldCenterOfMass ​

type : Insight.Vector3

(只读)刚体在世界空间的重心。

Methods ​


toString ​

javascript
toString(): string;

将 rigidbody 内容以一定格式转为 string 类型。

addForce ​

javascript
addForce(force: Insight.Vector3, mode: number): void;

对刚体施加一个世界空间的作用力。

Parameters

  • force : Insight.Vector3 世界空间中的力
  • mode : number 施力模式,参见 ForceMode

addForceAtLocalPosition ​

javascript
addForceAtLocalPosition(force: Insight.Vector3, position: Insight.Vector3, mode: number): void;

对刚体施加一个世界空间的作用力。

Parameters

  • force : Insight.Vector3 世界空间中的力
  • position : Insight.Vector3 局部空间中作用力的位置
  • mode : number 施力模式,参见 ForceMode

addForceAtPosition ​

javascript
addForceAtPosition(force: Insight.Vector3, position: Insight.Vector3, mode: number): void;

对刚体施加一个世界空间的作用力。

Parameters

  • force : Insight.Vector3 世界空间中的力
  • position : Insight.Vector3 世界空间中作用力的位置
  • mode : number 施力模式,参见 ForceMode

addRelativeForce ​

javascript
addRelativeForce(force: Insight.Vector3, mode: number): void;

对刚体施加一个局部空间的作用力。

Parameters

  • force : Insight.Vector3 局部空间中的力
  • mode : number 施力模式,参见 ForceMode

addRelativeForceAtLocalPosition ​

javascript
addRelativeForceAtLocalPosition(force: Insight.Vector3, position: Insight.Vector3, mode: number): void;

对刚体施加一个局部空间的作用力。

Parameters

  • force : Insight.Vector3 局部空间中的力
  • position : Insight.Vector3 局部空间中作用力的位置
  • mode : number 施力模式,参见 ForceMode

addRelativeForceAtPosition ​

javascript
addRelativeForceAtPosition(force: Insight.Vector3, position: Insight.Vector3, mode: number): void;

对刚体施加一个局部空间的作用力。

Parameters

  • force : Insight.Vector3 局部空间中的力
  • position : Insight.Vector3 世界空间中作用力的位置
  • mode : number 施力模式,参见 ForceMode

addRelativeTorque ​

javascript
addRelativeTorque(force: Insight.Vector3, mode: number): void;

对刚体施加一个局部空间的旋转力。

Parameters

  • force : Insight.Vector3 局部空间中的旋转力
  • mode : number 施力模式,参见 ForceMode

addTorque ​

javascript
addTorque(force: Insight.Vector3, mode: number): void;

对刚体施加一个世界空间的旋转力。

Parameters

  • force : Insight.Vector3 世界空间中的旋转力
  • mode : number 施力模式,参见 ForceMode

isSleeping ​

javascript
isSleeping(): boolean;

刚体是否正在休眠。

movePosition ​

javascript
movePosition(position: Insight.Vector3): void;

设置刚体的位置。

如果是 Dynamic Rigidbody,本方法会直接将刚体移动到指定位置。 如果是 Kinematic Rigidbody,本方法会将刚体平滑地移动到指定位置。

Parameters

moveRotation ​

javascript
moveRotation(rotation: Insight.Quaternion): void;

设置刚体的旋转。

如果是 Dynamic Rigidbody,本方法会直接将刚体转动到指定旋转。 如果是 Kinematic Rigidbody,本方法会将刚体平滑地转动到指定旋转。

Parameters

setDensity ​

javascript
setDensity(density : number): void;

设置刚体的密度,忽略 mass 设置。

Parameters

  • density : number 刚体的密度

wakeUp ​

javascript
wakeUp(): void;

唤醒刚体。

Inherited Properties(继承自 Component) ​


enabled ​

type : boolean

该组件是否是可用的。

gameObject ​

type :Insight.GameObject

(只读)该组件所依附的 GameObject。

isActiveAndEnabled ​

type : boolean

(只读)该组件是否可用,且其依附的 GameObject 是否是活跃状态。

name ​

type : string

(只读)所依附的 GameObject 的名称。

tag ​

type : string

(只读)所依附的 GameObject 的 Tag。

⚠️ 暂时未启用

transform ​

type :Insight.Transform

(只读)所依附的 GameObject 的 transform。