better isFalling detection

This commit is contained in:
nexovec 2022-01-29 21:46:46 +01:00
parent 9294c2b8f1
commit c9d2ef15ce
2 changed files with 5 additions and 5 deletions

View File

@ -108,14 +108,14 @@ public class PlayerController : MonoBehaviour
{ {
if (jump) if (jump)
{ {
Debug.Log("Jump"); // Debug.Log("Jump");
rb.AddForce(transform.up * jumpSpeed * 100 * Time.deltaTime, ForceMode.Impulse); rb.AddForce(transform.up * jumpSpeed * 100 * Time.deltaTime, ForceMode.Impulse);
jump = false; 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; this.isFalling = true;
} }
else else
@ -148,7 +148,7 @@ public class PlayerController : MonoBehaviour
if (pushObject != null) if (pushObject != null)
{ {
PlatformManager platform = pullObject.GetComponent<PlatformManager>(); PlatformManager platform = pushObject.GetComponent<PlatformManager>();
if (platform != null) if (platform != null)
{ {
float step = platform.speed * Time.deltaTime * 10f; float step = platform.speed * Time.deltaTime * 10f;

View File

@ -34,7 +34,7 @@ public class ProceduralGeneration : MonoBehaviour
float horizontalDistancePerPlatform = (float)Random.Range(1.0f, levelBlocks.Count); ; float horizontalDistancePerPlatform = (float)Random.Range(1.0f, levelBlocks.Count); ;
List<GameObject> levelBlocksSpawnTemp = new List<GameObject>(); List<GameObject> levelBlocksSpawnTemp = new List<GameObject>();
Debug.Log("Building LOOP"); // Debug.Log("Building LOOP");
int pieceCount = 10; int pieceCount = 10;
float radius = (pieceCount / 2) * 2; float radius = (pieceCount / 2) * 2;