30 lines
604 B
C#
30 lines
604 B
C#
using UnityEngine;
|
|
|
|
namespace UltimateWater
|
|
{
|
|
public class RiverCurrent : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private River _River;
|
|
|
|
[SerializeField]
|
|
[Tooltip("Scale of the force applied")]
|
|
private float _Force = 1f;
|
|
|
|
private Rigidbody _Rigidbody;
|
|
|
|
private Transform _Transform;
|
|
|
|
private void Awake()
|
|
{
|
|
_Transform = GetComponent<Transform>();
|
|
_Rigidbody = GetComponent<Rigidbody>();
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
_Rigidbody.AddForceAtPosition(_River.GetCurrentForce(_Transform.position) * _Force, new Vector3(_Transform.position.x, 0f, _Transform.position.z));
|
|
}
|
|
}
|
|
}
|