mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-29 08:37:58 +01:00
29 lines
515 B
C#
29 lines
515 B
C#
|
using UnityEngine;
|
||
|
|
||
|
public class FiePhysicalForceDynamic : MonoBehaviour
|
||
|
{
|
||
|
public float coefficient;
|
||
|
|
||
|
private Vector3 _nowNormalVec = Vector3.zero;
|
||
|
|
||
|
private float _nowForce;
|
||
|
|
||
|
public void Awake()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
private void OnTriggerStay(Collider col)
|
||
|
{
|
||
|
if (!(col.GetComponent<Rigidbody>() == null))
|
||
|
{
|
||
|
col.GetComponent<Rigidbody>().AddForce(coefficient * _nowNormalVec * _nowForce);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void SetPhysicalForce(Vector3 normalVec, float force)
|
||
|
{
|
||
|
_nowNormalVec = normalVec;
|
||
|
_nowForce = force;
|
||
|
}
|
||
|
}
|