TO SQUASH: Eye ball reorientation towards bar.
This commit is contained in:
@@ -29,18 +29,18 @@ public class BallSpawner : MonoBehaviour
|
||||
{
|
||||
int currentLevel = PlayerPrefs.GetInt("CurrentLevel");
|
||||
|
||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(oozeBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(nuclearBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(oozeBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(nuclearBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(eyeBallPrefab));
|
||||
|
||||
StartCoroutine(SpawnBalls());
|
||||
|
||||
@@ -2,6 +2,8 @@ using UnityEngine;
|
||||
|
||||
public class EyeBall : BallBase
|
||||
{
|
||||
private static float reorientationAngleDegrees = 3f;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
@@ -17,7 +19,24 @@ public class EyeBall : BallBase
|
||||
{
|
||||
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
|
||||
|
||||
// TODO: Adjust eye ball direction based on the player's bar if active.
|
||||
// Adjust eye ball direction based on the player's bar if active.
|
||||
var barSegments = GameObject.FindGameObjectsWithTag("Bar");
|
||||
|
||||
if (barSegments.Length > 0)
|
||||
{
|
||||
// For simplicity, just take the first bar segment found.
|
||||
var barSegment = barSegments[0];
|
||||
Vector3 directionToBar = (barSegment.transform.position - transform.position).normalized;
|
||||
float currentSpeed = speed.magnitude;
|
||||
|
||||
if (currentSpeed > 0f)
|
||||
{
|
||||
float signedAngle = Vector2.SignedAngle(speed.normalized, (Vector2)directionToBar);
|
||||
float clampedAngle = Mathf.Clamp(signedAngle, -reorientationAngleDegrees, reorientationAngleDegrees);
|
||||
Vector2 smoothDirection = (Vector2)(Quaternion.Euler(0f, 0f, clampedAngle) * speed.normalized);
|
||||
speed = smoothDirection * currentSpeed; // Maintain current speed magnitude
|
||||
}
|
||||
}
|
||||
|
||||
if (stateInfo.IsName("EyeBallMove")) {
|
||||
transform.Translate(speed);
|
||||
|
||||
Reference in New Issue
Block a user