Version: 2022.3
언어: 한국어
public void AddRelativeTorque (Vector3 torque, ForceMode mode= ForceMode.Force);

파라미터

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

설명

Applies a torque to the articulation body, relative to its local coordinate system.

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

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

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

Applying a torque to an ArticulationBody wakes up that body. If the torque size is zero then the ArticulationBody does not wake up.
Unit of measurement - Nm (newton-meters).

See Also: AddTorque, AddRelativeForce.

// Rotate an object around its Y (upward) axis in response to
// left/right controls.

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { public float torque; public ArticulationBody ab;

void Start() { ab = GetComponent<ArticulationBody>(); }

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