From c9d2ef15ce8f42554163cf2d538b5c66692b6bdd Mon Sep 17 00:00:00 2001 From: nexovec Date: Sat, 29 Jan 2022 21:46:46 +0100 Subject: [PATCH] better isFalling detection --- Assets/Scripts/PlayerController.cs | 8 ++++---- Assets/Scripts/ProceduralGeneration.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 8666acd..14f6c6b 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -108,14 +108,14 @@ public class PlayerController : MonoBehaviour { if (jump) { - Debug.Log("Jump"); + // Debug.Log("Jump"); rb.AddForce(transform.up * jumpSpeed * 100 * Time.deltaTime, ForceMode.Impulse); jump = false; } - if(rb.velocity.magnitude != 0 && rb.velocity.normalized == this.downDirection.normalized) + if(rb.velocity.magnitude != 0 && Vector3.Dot(rb.velocity.normalized, Physics.gravity.normalized) > 0 ) { - // Debug.Log("Player is falling :)"); + Debug.Log("Player is falling :)"); this.isFalling = true; } else @@ -148,7 +148,7 @@ public class PlayerController : MonoBehaviour if (pushObject != null) { - PlatformManager platform = pullObject.GetComponent(); + PlatformManager platform = pushObject.GetComponent(); if (platform != null) { float step = platform.speed * Time.deltaTime * 10f; diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs index 841d608..6edbacb 100644 --- a/Assets/Scripts/ProceduralGeneration.cs +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -34,7 +34,7 @@ public class ProceduralGeneration : MonoBehaviour float horizontalDistancePerPlatform = (float)Random.Range(1.0f, levelBlocks.Count); ; List levelBlocksSpawnTemp = new List(); - Debug.Log("Building LOOP"); + // Debug.Log("Building LOOP"); int pieceCount = 10; float radius = (pieceCount / 2) * 2;