Files
BABA_YAGA/Assets/Third Parties/Opsive/UltimateCharacterController/Scripts/Traits/RigidbodyImpulse.cs
Scove 3e39117acc Consolidate third-party plugins into Assets/Plugins
Move and consolidate many third-party plugin files and metadata from various locations (notably Assets/Third Parties/Plugins 1 and scattered Opsive/Photon folders) into a unified Assets/Plugins directory. Includes DOTween, PrimeTween, Native/BackroomsNoise, Sirenix/Odin Inspector, and Opsive UltimateCharacterController/shared libs, plus updates to several .meta files and removal of obsolete installer/legacy files. This standardizes plugin layout and cleans up duplicate/obsolete assets.
2026-06-16 18:41:44 +07:00

54 lines
1.8 KiB
C#

/// ---------------------------------------------
/// Ultimate Character Controller
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.UltimateCharacterController.Traits
{
using Opsive.UltimateCharacterController.Utility;
using UnityEngine;
/// <summary>
/// Applies an impulse to the Rigidbody when enabled.
/// </summary>
public class RigidbodyImpulse : MonoBehaviour
{
[Tooltip("Should the force be applied in the local space?")]
[SerializeField] protected bool m_LocalForce = true;
[Tooltip("The force to apply to the Rigidbody.")]
[SerializeField] protected MinMaxVector3 m_Force = new MinMaxVector3(new Vector3(0, 5, 0), new Vector3(0, 5, 0));
[Tooltip("Should the torque be applied in the local space?")]
[SerializeField] protected bool m_LocalTorque = true;
[Tooltip("The torque to apply to the Rigidbody.")]
[SerializeField] protected MinMaxVector3 m_Torque;
private Rigidbody m_Rigidbody;
/// <summary>
/// Initialize the default values.
/// </summary>
private void Awake()
{
m_Rigidbody = GetComponent<Rigidbody>();
}
/// <summary>
/// Add the impulse force.
/// </summary>
private void OnEnable()
{
if (m_LocalForce) {
m_Rigidbody.AddRelativeForce(m_Force.RandomValue, ForceMode.Impulse);
} else {
m_Rigidbody.AddForce(m_Force.RandomValue, ForceMode.Impulse);
}
if (m_LocalTorque) {
m_Rigidbody.AddRelativeTorque(m_Torque.RandomValue);
} else {
m_Rigidbody.AddTorque(m_Torque.RandomValue);
}
}
}
}