RigidbodySynchronizableAddTorque(Vector3, ForceMode) Method
Adds a torque to the rigidbody.
Namespace: AlterunaAssembly: Alteruna.Trinity (in Alteruna.Trinity.dll) Version: 1.3.4
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.
Force can be applied only to an active rigidbody. If a GameObject is inactive, AddTorque has no effect.
// 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);
}
}
Reference
[!:https://docs.unity3d.com/ScriptReference/Rigidbody.AddTorque.html]