Player movement tweaks, bugfxes; Docs

This commit is contained in:
RochesterX
2025-04-16 19:20:36 -04:00
parent 186811be42
commit 5dee952cad
432 changed files with 66953 additions and 481 deletions

View File

@@ -13,7 +13,7 @@ public class MovingPlatform : MonoBehaviour
transform.position = points[startPoint].position;
}
void Update()
void FixedUpdate()
{
// If the platform is close to the target point, it starts moving to the next one
if (Vector2.Distance(transform.position, points[i].position) < 0.02f)
@@ -25,6 +25,7 @@ public class MovingPlatform : MonoBehaviour
}
}
// Moves the platform towards the next point
transform.position = Vector2.MoveTowards(transform.position, points[i].position, speed * Time.deltaTime);
// transform.position = Vector2.MoveTowards(transform.position, points[i].position, speed * Time.deltaTime);
GetComponent<Rigidbody2D>().MovePosition(Vector2.MoveTowards(transform.position, points[i].position, speed * Time.fixedDeltaTime));
}
}

View File

@@ -20,6 +20,7 @@ public class RespawnOnTriggerEnter : MonoBehaviour
{
if (TryGetComponent(out Damageable damageable))
{
print("Voided out " + other.name);
damageable.Damage(9999f);
}
}

View File

@@ -77,7 +77,7 @@ public class Damageable : MonoBehaviour
public void Damage(float damage) // Adds damage to player when hit
{
if (GameManager.Instance.gameOver) return; // Prevent damage after game is over
//if (GameManager.Instance.gameOver) return; // Prevent damage after game is over
this.damage += damage;
if (damage >= maxDamage)

View File

@@ -95,16 +95,26 @@ public class PlayerMovement : MonoBehaviour
animationPlayer.SetState(AnimationPlayer.AnimationState.Jump);
else
{
if (Mathf.Abs(body.linearVelocityX) >= 0.05f)
if (Mathf.Abs(virtualAxisX) >= 0.05f)
animationPlayer.SetState(GameManager.Instance.gameOver ? AnimationPlayer.AnimationState.Walk : AnimationPlayer.AnimationState.Run);
else
animationPlayer.SetState(AnimationPlayer.AnimationState.Idle);
}
if (body.linearVelocityX < -0.1f)
animationPlayer.backwards = true;
else if (body.linearVelocityX > 0.1f)
animationPlayer.backwards = false;
if (true)
{
if (virtualAxisX < -0.01f)
animationPlayer.backwards = true;
else if (virtualAxisX > 0.01f)
animationPlayer.backwards = false;
}
else
{
if (body.linearVelocityX < -0.1f)
animationPlayer.backwards = true;
else if (body.linearVelocityX > 0.1f)
animationPlayer.backwards = false;
}
}
private void Land() // Stops jumping when player lands