mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
29 lines
969 B
C#
29 lines
969 B
C#
using ABI.CCK.Components;
|
|
using ABI_RC.Systems.Movement;
|
|
using UnityEngine;
|
|
|
|
namespace ml_prm
|
|
{
|
|
[DisallowMultipleComponent]
|
|
class GravityInfluencer : MonoBehaviour
|
|
{
|
|
Rigidbody m_rigidBody = null;
|
|
PhysicsInfluencer m_physicsInfluencer = null;
|
|
bool m_activeGravity = true;
|
|
|
|
void Start()
|
|
{
|
|
m_rigidBody = this.GetComponent<Rigidbody>();
|
|
m_physicsInfluencer = this.GetComponent<PhysicsInfluencer>();
|
|
}
|
|
|
|
void FixedUpdate()
|
|
{
|
|
m_rigidBody.useGravity = false;
|
|
if(m_activeGravity && ((m_physicsInfluencer == null) || !m_physicsInfluencer.enableInfluence || !m_physicsInfluencer.GetSubmerged()))
|
|
m_rigidBody.AddForce(BetterBetterCharacterController.Instance.GravityResult.AppliedGravity * m_rigidBody.mass);
|
|
}
|
|
|
|
public void SetActiveGravity(bool p_state) => m_activeGravity = p_state;
|
|
}
|
|
}
|