/// <summary> /// Handles collison of objects with the ground /// </summary> void DoCollisionDetectionGround() { foreach (AABB ground in groundTiles) { bool resultGround = player.checkOverlap(ground); //print(resultGround); if (resultGround == true) { Vector3 fix = player.CalculateOverlapFix(ground); //print(fix); player.GetComponent <PlayerController>().ApplyFix(fix); } foreach (AABB thowmp in thowmps) { bool resultThowmp = thowmp.checkOverlap(ground); if (resultThowmp == true && thowmp != null) { Vector3 fix = thowmp.CalculateOverlapFix(ground); //print(fix); //player.GetComponent<PlayerController>().ApplyFix(fix); thowmp.GetComponent <Osilate>().isMovingDown = false; } } } }
/// Ground /// Lava /// Spike /// PowerUp /// Wall /// <summary> /// Collision Detection - Ground /// Detects collision between player and ground /// Fixes player location to always stay ontop of the ground /// Gravity is stopped for the player allowing for the player to jump /// </summary> void DoCollisionDetectionGround() { foreach (AABB ground in groundTiles) { bool resultGround = player.checkOverlap(ground); //print(resultGround); if (resultGround == true) { //player.transform.position = new Vector3(player.transform.position.x, player.transform.position.y + 5 * Time.deltaTime, player.transform.position.z); //player.GetComponent<PlayerController>().stopGravity = true; //player.GetComponent<MeshRenderer>().material.color = Color.black; Vector3 fix = player.CalculateOverlapFix(ground); // print(fix); player.GetComponent <PlayerController>().ApplyFix(fix); return; } else { player.GetComponent <PlayerController>().stopGravity = false; //player.GetComponent<MeshRenderer>().material.color = Color.blue; } } }