Version: 2023.2
public void AddRelativeForce (Vector3 force, ForceMode mode= ForceMode.Force);

参数

force The force vector in local coordinates.
mode The type of force to apply.

描述

Applies a force to the Articulation Body, relative to its local coordinate system.

You can only apply a force to an active ArticulationBody. If a GameObject is inactive, AddRelativeForce has no effect.

ForceMode.Force and ForceMode.Acceleration modes modify the Linear Velocity Per Second accumulator and ForceMode.Impulse and ForceMode.VelocityChange modify the Linear Velocity Per Step accumulator. Mixing these 2 groups of ForceModes doesn't work for Articulation Bodies and will result in only the Linear Velocity Per Second accumulator being applied.

For more information on how ForceMode affects velocity, see Rigidbody.AddForce.

Applying a force to an ArticulationBody wakes up that body. If the force size is zero then the ArticulationBody does not wake up.
Unit of measurement - N (newtons).

另请参阅:AddForceAddForceAtPositionAddRelativeTorque

using UnityEngine;
using System.Collections;

// Add a thrust force to push an object in its current forward // direction (to simulate a rocket motor, say). public class ExampleClass : MonoBehaviour { public float thrust; public ArticulationBody ab; void Start() { ab = GetComponent<ArticulationBody>(); }

void FixedUpdate() { ab.AddRelativeForce(Vector3.forward * thrust); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961