Version: 2021.2

ArticulationBody.AddRelativeTorque

切换到手册
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.

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).

另请参阅:AddTorqueAddRelativeForce

// 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); } }