RigidbodySynchronizableAddTorque(Vector3, ForceMode) Method

Adds a torque to the rigidbody.

Definition

Namespace: Alteruna
Assembly: Alteruna.Trinity (in Alteruna.Trinity.dll) Version: 1.3.4
C#
public void AddTorque(
	Vector3 torque,
	ForceMode mode = 0
)

Parameters

torque  Vector3
Torque vector in world coordinates.
mode  ForceMode  (Optional)
The type of torque to apply.

Example

Force can be applied only to an active rigidbody. If a GameObject is inactive, AddTorque has no effect.
C#
// 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 RigidbodySynchronizable rb;

    void FixedUpdate()
    {
        float turn = Input.GetAxis("Horizontal");
        rb.AddTorque(transform.up * torque * turn);
    }
}

See Also

Reference

[!:https://docs.unity3d.com/ScriptReference/Rigidbody.AddTorque.html]