mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-22 13:58:00 +01:00
28 lines
515 B
C#
28 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;
|
|
}
|
|
}
|