The worker respects the splines now
This commit is contained in:
@@ -25,7 +25,9 @@ public class WorkerBeltRoamingBehaviour : AppleState
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
workerAnimator.SetBool("isLifting?", false);
|
||||
if (workerAnimator != null)
|
||||
workerAnimator.SetBool("isLifting?", false);
|
||||
|
||||
Debug.Log("Entered Worker Belt Roaming State");
|
||||
|
||||
if (RoamingSpline == null || workerObjectTransform == null)
|
||||
@@ -46,35 +48,47 @@ public class WorkerBeltRoamingBehaviour : AppleState
|
||||
// Also stop the tween if the GameObject is disabled for any reason (covers StateMachine deactivation)
|
||||
void OnDisable()
|
||||
{
|
||||
midRoamPosition = workerObjectTransform.position;
|
||||
Debug.Log("WorkerBeltRoamingBehaviour: OnExitState - stopping roaming tween" + midRoamPosition);
|
||||
if (workerObjectTransform != null)
|
||||
midRoamPosition = workerObjectTransform.position;
|
||||
Debug.Log("WorkerBeltRoamingBehaviour: Stopping roaming tween " + midRoamPosition);
|
||||
roamingTween?.Stop();
|
||||
roamingTween = null;
|
||||
|
||||
if (pantsRoutine != null)
|
||||
{
|
||||
StopCoroutine(pantsRoutine);
|
||||
pantsRoutine = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (RoamingSpline.GetDirection(roamingTween.Percentage).x > 0.1)
|
||||
workerAnimator.SetBool("walkingRight?", true);
|
||||
if (RoamingSpline == null || roamingTween == null)
|
||||
return;
|
||||
|
||||
float pct = Mathf.Clamp01(roamingTween.Percentage);
|
||||
Vector3 dir = RoamingSpline.GetDirection(pct);
|
||||
if (dir.x > 0.1f)
|
||||
workerAnimator?.SetBool("walkingRight?", true);
|
||||
else
|
||||
workerAnimator.SetBool("walkingRight?", false);
|
||||
workerAnimator?.SetBool("walkingRight?", false);
|
||||
}
|
||||
|
||||
IEnumerator RandomFallChance()
|
||||
{
|
||||
while (pantsLess)
|
||||
{
|
||||
yield return new WaitForSeconds(2);
|
||||
CheckForFall();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckForFall()
|
||||
{
|
||||
int _randNumber;
|
||||
_randNumber = Random.Range(0, 1);
|
||||
|
||||
if (_randNumber > 5)
|
||||
// 5% chance to fall each check
|
||||
if (Random.value < 0.05f)
|
||||
{
|
||||
workerAnimator.SetTrigger("shouldFall?");
|
||||
workerAnimator?.SetTrigger("shouldFall?");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +97,7 @@ public class WorkerBeltRoamingBehaviour : AppleState
|
||||
if (pantsRoutine != null)
|
||||
{
|
||||
StopCoroutine(pantsRoutine);
|
||||
pantsRoutine = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user