Version: 2021.3
LanguageEnglish
  • C#

ArticulationBody.AddTorque

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Declaration

public void AddTorque(Vector3 torque, ForceMode mode = ForceMode.Force);

Parameters

torque The torque to apply.
mode The type of torque to apply.

Description

Add torque to the articulation body.

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

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

Additional resources: AddRelativeTorque, AddForce.

// 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.AddTorque(transform.up * torque * turn); } }