Add camera lower bound

This commit is contained in:
RochesterX
2025-03-08 21:04:15 -05:00
parent a7db5649cb
commit 2e407206bc
5 changed files with 2418 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ public class PlayerCameraMovement : MonoBehaviour
public float weight;
public float speed;
private GameObject playerThatWon;
public float lowerBound;
public bool winScene = false;
@@ -53,6 +54,7 @@ public class PlayerCameraMovement : MonoBehaviour
target = start * weight + playerAverage * (1 - weight);
transform.position = Vector3.Lerp(transform.position, new Vector3(target.x, target.y, transform.position.z), speed * Time.deltaTime);
transform.position = new Vector3(Mathf.Clamp(transform.position.x, lowerBound, Mathf.Infinity), transform.position.y, transform.position.z);
}
public void WinScene(GameObject player)

View File

@@ -71,7 +71,7 @@ public class PlayerMovement : MonoBehaviour
private void Update()
{
if (GameManager.Instance.gameOver) maxSpeed = 0.1f;
if (GameManager.Instance.gameOver) maxSpeed = 1f;
if (damageable.dying/* || (GameManager.Instance != null && GameManager.Instance.gameOver)*/) return;
Jump();
@@ -99,7 +99,7 @@ public class PlayerMovement : MonoBehaviour
animationPlayer.SetState(AnimationPlayer.AnimationState.Jump);
else
{
if (Mathf.Abs(body.linearVelocityX) >= 0.5f)
if (Mathf.Abs(body.linearVelocityX) >= 0.05f)
animationPlayer.SetState(GameManager.Instance.gameOver ? AnimationPlayer.AnimationState.Walk : AnimationPlayer.AnimationState.Run);
else
animationPlayer.SetState(AnimationPlayer.AnimationState.Idle);