rev 0.4, dev panel
This commit is contained in:
@@ -101,13 +101,14 @@ public class Puck : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
public void Reset(float duration)
|
||||
public void Reset(Vector3? position = null, float duration = 0.5f)
|
||||
{
|
||||
StartCoroutine(CoroutineReset(duration));
|
||||
Vector3 pos = position ?? startPosition;
|
||||
StartCoroutine(CoroutineReset(pos, duration));
|
||||
}
|
||||
Coroutine coroutineScheduleReset;
|
||||
public void ScheduleReset(float duration = 0.5f){
|
||||
coroutineScheduleReset = StartCoroutine(CoroutineScheduleReset(duration));
|
||||
public void ScheduleReset(Vector3 position, float duration = 0.5f){
|
||||
coroutineScheduleReset = StartCoroutine(CoroutineScheduleReset(position, duration));
|
||||
}
|
||||
|
||||
public void UnscheduleReset(){
|
||||
@@ -116,20 +117,25 @@ public class Puck : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator CoroutineScheduleReset(float duration){
|
||||
IEnumerator CoroutineScheduleReset(Vector3 position, float duration){
|
||||
while(GameManager.isMoving){
|
||||
yield return null;
|
||||
}
|
||||
Reset(duration);
|
||||
|
||||
Debug.Log("Resetting puck", gameObject);
|
||||
Vector3 dir = position - transform.position;
|
||||
dir = dir.normalized;
|
||||
position += dir * 1.25f;
|
||||
Reset(position, duration);
|
||||
}
|
||||
|
||||
IEnumerator CoroutineReset(float duration){
|
||||
IEnumerator CoroutineReset(Vector3 pos, float duration){
|
||||
float t=0;
|
||||
Vector3 pos1 = transform.position;
|
||||
Quaternion rot1 = transform.rotation;
|
||||
while(t<duration){
|
||||
t+=Time.deltaTime;
|
||||
transform.position = Vector3.Lerp(pos1, startPosition, t/duration);
|
||||
transform.position = Vector3.Lerp(pos1, pos, t/duration);
|
||||
transform.rotation = Quaternion.Lerp(rot1, Quaternion.identity, t/duration);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user