Fix player movement on screens

This commit is contained in:
Lncvrt committed 2026-03-03 23:05:15 -07:00
1 parent 8a6886f7d0
commit f3fee721ad
6 files changed
+44 -41

No files matched your search

+9 -8
View File
@@ -197,21 +197,21 @@ public class AutoGamePlayer : MonoBehaviour {
}
}
if (doMoveLeft && !doMoveRight) {
bird.transform.position += new UnityEngine.Vector3(-(1.7f * speedModifier), 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(-(2.4f * (speedModifier * canvasRect.lossyScale.x)), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(1f, 1f, 1f);
}
if (doMoveRight && !doMoveLeft) {
bird.transform.position += new UnityEngine.Vector3(1.7f * speedModifier, 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(2.4f * (speedModifier * canvasRect.lossyScale.x), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(-1f, 1f, 1f);
}
if (doMoveLeft || doMoveRight) groundCollider.transform.position = new(bird.transform.position.x, groundCollider.transform.position.y);
if (doJump && IsGrounded()) {
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 380f);
else if (slownessLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 220f);
else rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 300f);
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 480f * canvasRect.lossyScale.y);
else if (slownessLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 300f * canvasRect.lossyScale.y);
else rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 380f * canvasRect.lossyScale.y);
}
if (doBack) {
TogglePause();
@@ -278,7 +278,7 @@ public class AutoGamePlayer : MonoBehaviour {
float spawnProbability = UnityEngine.Random.value;
if (!pausePanel.activeSelf) {
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
newBerry.transform.SetParent(berryParent.transform);
newBerry.transform.SetParent(berryParent.transform, false);
if (spawnProbability <= 0.425f) {
newBerry.sprite = Resources.Load<Sprite>("Berries/Berry");
@@ -315,6 +315,7 @@ public class AutoGamePlayer : MonoBehaviour {
}
void Update() {
if (!pausePanel.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None)) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
GameObject[] allBerries = GameObject.FindGameObjectsWithTag("NormalBerry")
@@ -358,7 +359,7 @@ public class AutoGamePlayer : MonoBehaviour {
break;
}
}
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? -200f : -375f);
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-200f * canvasRect.lossyScale.y) : (-375f * canvasRect.lossyScale.y));
}
else foreach (GameObject berry in allBerries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
@@ -425,7 +426,7 @@ public class AutoGamePlayer : MonoBehaviour {
}
internal void DisablePause() {
rb.gravityScale = 80f;
rb.gravityScale = 100f * canvasRect.lossyScale.y;
rb.linearVelocity = velocityBeforePause;
velocityBeforePause = new();
if (AutoGamePlayerPauseMenu.Instance.statsMenu.activeSelf) {
+11 -10
View File
@@ -150,12 +150,12 @@ public class CustomGamePlayer : MonoBehaviour {
}
}
if (doMoveLeft && !doMoveRight) {
bird.transform.position += new UnityEngine.Vector3(-(1.7f * speedModifier), 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(-(2.4f * (speedModifier * canvasRect.lossyScale.x)), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(1f, 1f, 1f);
}
if (doMoveRight && !doMoveLeft) {
bird.transform.position += new UnityEngine.Vector3(1.7f * speedModifier, 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(2.4f * (speedModifier * canvasRect.lossyScale.x), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(-1f, 1f, 1f);
}
@@ -324,21 +324,21 @@ public class CustomGamePlayer : MonoBehaviour {
}
}
if (doMoveLeft && !doMoveRight) {
bird.transform.position += new UnityEngine.Vector3(-(1.7f * speedModifier), 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(-(2.4f * (speedModifier * canvasRect.lossyScale.x)), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(1f, 1f, 1f);
}
if (doMoveRight && !doMoveLeft) {
bird.transform.position += new UnityEngine.Vector3(1.7f * speedModifier, 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(2.4f * (speedModifier * canvasRect.lossyScale.x), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(-1f, 1f, 1f);
}
if (doMoveLeft || doMoveRight) groundCollider.transform.position = new(bird.transform.position.x, groundCollider.transform.position.y);
if (doJump && IsGrounded()) {
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 380f);
else if (slownessLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 220f);
else rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 300f);
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 480f * canvasRect.lossyScale.y);
else if (slownessLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 300f * canvasRect.lossyScale.y);
else rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 380f * canvasRect.lossyScale.y);
}
if (doBack) {
TogglePause();
@@ -407,7 +407,7 @@ public class CustomGamePlayer : MonoBehaviour {
if (!pausePanel.activeSelf) {
float cumulative = 0f;
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
newBerry.transform.SetParent(berryParent.transform);
newBerry.transform.SetParent(berryParent.transform, false);
cumulative += normalBerryChance / 100f;
if (spawnProbability <= cumulative) {
@@ -473,6 +473,7 @@ public class CustomGamePlayer : MonoBehaviour {
}
void Update() {
if (!pausePanel.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None)) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
GameObject[] allBerries = GameObject.FindGameObjectsWithTag("NormalBerry")
@@ -519,7 +520,7 @@ public class CustomGamePlayer : MonoBehaviour {
break;
}
}
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? -200f : -375f);
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-200f * canvasRect.lossyScale.y) : (-375f * canvasRect.lossyScale.y));
}
else foreach (GameObject berry in allBerries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
@@ -575,7 +576,7 @@ public class CustomGamePlayer : MonoBehaviour {
}
internal void DisablePause() {
rb.gravityScale = 80f;
rb.gravityScale = 100f * canvasRect.lossyScale.y;
rb.linearVelocity = velocityBeforePause;
velocityBeforePause = new();
if (CustomGamePlayerPauseMenu.Instance.editingUI == true) {
+9 -8
View File
@@ -136,21 +136,21 @@ public class GamePlayer : MonoBehaviour {
}
}
if (doMoveLeft && !doMoveRight) {
bird.transform.position += new UnityEngine.Vector3(-(1.7f * speedModifier), 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(-(2.4f * (speedModifier * canvasRect.lossyScale.x)), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(1f, 1f, 1f);
}
if (doMoveRight && !doMoveLeft) {
bird.transform.position += new UnityEngine.Vector3(1.7f * speedModifier, 0f, 0f);
bird.transform.position += new UnityEngine.Vector3(2.4f * (speedModifier * canvasRect.lossyScale.x), 0f, 0f);
ClampPosition(bird);
bird.transform.localScale = new UnityEngine.Vector3(-1f, 1f, 1f);
}
if (doMoveLeft || doMoveRight) groundCollider.transform.position = new(bird.transform.position.x, groundCollider.transform.position.y);
if (doJump && IsGrounded()) {
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Jump"), Camera.main.transform.position, 0.75f * BazookaManager.Instance.GetSettingSFXVolume());
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 380f);
else if (slownessLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 220f);
else rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 300f);
if (boostLeft > 0f || speedyLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 480f * canvasRect.lossyScale.y);
else if (slownessLeft > 0f) rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 300f * canvasRect.lossyScale.y);
else rb.linearVelocity = new UnityEngine.Vector2(rb.linearVelocity.x, 380f * canvasRect.lossyScale.y);
}
if (doBack) {
TogglePause();
@@ -220,7 +220,7 @@ public class GamePlayer : MonoBehaviour {
float spawnProbability = UnityEngine.Random.value;
if (!pausePanel.activeSelf) {
Image newBerry = Instantiate(berryTemplate).GetComponent<Image>();
newBerry.transform.SetParent(berryParent.transform);
newBerry.transform.SetParent(berryParent.transform, false);
if (spawnProbability <= 0.375f) {
newBerry.sprite = Resources.Load<Sprite>("Berries/Berry");
@@ -260,6 +260,7 @@ public class GamePlayer : MonoBehaviour {
}
void Update() {
if (!pausePanel.activeSelf && rb.gravityScale != 100f * canvasRect.lossyScale.y) rb.gravityScale = 100f * canvasRect.lossyScale.y;
foreach (AudioSource audio in FindObjectsByType<AudioSource>(FindObjectsSortMode.None)) audio.pitch = speedyLeft > 0f ? 1.3f : 1f;
GameObject[] allBerries = GameObject.FindGameObjectsWithTag("NormalBerry")
@@ -306,7 +307,7 @@ public class GamePlayer : MonoBehaviour {
break;
}
}
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? -200f : -375f);
if (berry != null) berry.GetComponent<Rigidbody2D>().linearVelocity = new UnityEngine.Vector2(0f, speedyLeft == 0.0f ? (-200f * canvasRect.lossyScale.y) : (-375f * canvasRect.lossyScale.y));
}
else foreach (GameObject berry in allBerries) berry.GetComponent<Rigidbody2D>().linearVelocity = UnityEngine.Vector2.zero;
if ((Application.platform == RuntimePlatform.Android && Keyboard.current.escapeKey.wasPressedThisFrame) || !Application.isMobilePlatform && (Keyboard.current.escapeKey.wasPressedThisFrame || (Gamepad.current != null && (Gamepad.current.startButton.wasPressedThisFrame || Gamepad.current.buttonEast.wasPressedThisFrame)))) TogglePause();
@@ -390,7 +391,7 @@ public class GamePlayer : MonoBehaviour {
}
internal void DisablePause() {
rb.gravityScale = 80f;
rb.gravityScale = 100f * canvasRect.lossyScale.y;
rb.linearVelocity = velocityBeforePause;
velocityBeforePause = new();
if (GamePlayerPauseMenu.Instance.statsMenu.activeSelf) {