OldBlueWater/BlueWater/Assets/Crest/Crest-Examples/PirateCove/Scripts/ShipHandbrake.cs
2023-08-01 13:03:57 +09:00

44 lines
862 B
C#

// Crest Ocean System
// Copyright 2020 Wave Harmonic Ltd
using UnityEngine;
namespace Crest.Examples
{
[RequireComponent(typeof(Rigidbody))]
public class ShipHandbrake : MonoBehaviour
{
[SerializeField] bool _activeOnStart = true;
[SerializeField] float _timeToRelease = 1f;
Rigidbody _rb;
private void Start()
{
_rb = GetComponent<Rigidbody>();
if(_activeOnStart)
{
_rb.isKinematic = true;
}
}
private void Update()
{
_timeToRelease -= Time.deltaTime;
if(_timeToRelease <= 0f)
{
enabled = false;
_rb.isKinematic = false;
}
}
public void Release()
{
_rb.isKinematic = false;
}
}
}