|
|
@ -9,11 +9,11 @@ public class YeetController : MonoBehaviour, IYeetable |
|
|
|
public float yeetVelocity = 10f; |
|
|
|
public float yeetDuration = 2f; |
|
|
|
|
|
|
|
private float time; |
|
|
|
public enum YeetState { Unheld, Held, Yeeting }; |
|
|
|
public YeetState yeetState { get; private set; } = YeetState.Unheld; |
|
|
|
|
|
|
|
private GameObject _child; |
|
|
|
private float _time; |
|
|
|
|
|
|
|
public void Hold(GameObject child) |
|
|
|
{ |
|
|
@ -26,9 +26,9 @@ public class YeetController : MonoBehaviour, IYeetable |
|
|
|
public void Yeet() |
|
|
|
{ |
|
|
|
_child.transform.parent = null; |
|
|
|
|
|
|
|
_child.transform.rotation = parent.transform.rotation; |
|
|
|
yeetState = YeetState.Yeeting; |
|
|
|
time = yeetDuration; |
|
|
|
_time = yeetDuration; |
|
|
|
} |
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
@ -44,9 +44,9 @@ public class YeetController : MonoBehaviour, IYeetable |
|
|
|
{ |
|
|
|
case YeetState.Yeeting: |
|
|
|
_child.transform.position += _child.transform.forward * yeetVelocity * Time.deltaTime; |
|
|
|
time -= Time.deltaTime; |
|
|
|
_time -= Time.deltaTime; |
|
|
|
|
|
|
|
if(time <= 0f) |
|
|
|
if(_time <= 0f) |
|
|
|
{ |
|
|
|
yeetState = YeetState.Unheld; |
|
|
|
} |
|
|
|