Skip to content
Snippets Groups Projects
Commit f0794950 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

isGrounded check

parent 95a93ec0
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ Transform: ...@@ -29,7 +29,7 @@ Transform:
m_GameObject: {fileID: 8734763122887161289} m_GameObject: {fileID: 8734763122887161289}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0.37} m_LocalPosition: {x: 0, y: 0, z: -0.37}
m_LocalScale: {x: 2.0199616, y: 0.116242014, z: 2.0199616} m_LocalScale: {x: 1.5553703, y: 0.059997004, z: 1.5553703}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
......
...@@ -154,7 +154,7 @@ PrefabInstance: ...@@ -154,7 +154,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 22.94 value: 15.27
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -327,7 +327,7 @@ PrefabInstance: ...@@ -327,7 +327,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 8.25 value: 5.2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -413,7 +413,7 @@ PrefabInstance: ...@@ -413,7 +413,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 19.44 value: 13.06
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -487,7 +487,7 @@ PrefabInstance: ...@@ -487,7 +487,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 5.3 value: 3.16
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -669,7 +669,7 @@ PrefabInstance: ...@@ -669,7 +669,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 2.44 value: 1.18
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -736,7 +736,7 @@ GameObject: ...@@ -736,7 +736,7 @@ GameObject:
- component: {fileID: 1201936094} - component: {fileID: 1201936094}
- component: {fileID: 1201936093} - component: {fileID: 1201936093}
- component: {fileID: 1201936092} - component: {fileID: 1201936092}
m_Layer: 0 m_Layer: 7
m_Name: Plane m_Name: Plane
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
...@@ -832,7 +832,6 @@ GameObject: ...@@ -832,7 +832,6 @@ GameObject:
- component: {fileID: 1402473605} - component: {fileID: 1402473605}
- component: {fileID: 1402473604} - component: {fileID: 1402473604}
- component: {fileID: 1402473603} - component: {fileID: 1402473603}
- component: {fileID: 1402473602}
m_Layer: 0 m_Layer: 0
m_Name: Ball m_Name: Ball
m_TagString: Player m_TagString: Player
...@@ -840,22 +839,6 @@ GameObject: ...@@ -840,22 +839,6 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!54 &1402473602
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1402473601}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
m_CollisionDetection: 0
--- !u!135 &1402473603 --- !u!135 &1402473603
SphereCollider: SphereCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1277,7 +1260,7 @@ MonoBehaviour: ...@@ -1277,7 +1260,7 @@ MonoBehaviour:
groundCheckDistance: 0.1 groundCheckDistance: 0.1
groundMask: groundMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 256 m_Bits: 384
--- !u!114 &1801443372 --- !u!114 &1801443372
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1342,7 +1325,7 @@ PrefabInstance: ...@@ -1342,7 +1325,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 11.13 value: 7.31
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -1422,7 +1405,7 @@ PrefabInstance: ...@@ -1422,7 +1405,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 16.960001 value: 11.11
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -1699,7 +1682,7 @@ PrefabInstance: ...@@ -1699,7 +1682,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 13.83 value: 8.98
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
...@@ -1773,7 +1756,7 @@ PrefabInstance: ...@@ -1773,7 +1756,7 @@ PrefabInstance:
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: -0.37 value: -0.86
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468, - target: {fileID: 8734763122887161288, guid: b8e171ee62b94bf40a42322cb2d9c468,
type: 3} type: 3}
......
...@@ -14,6 +14,7 @@ public class BallBehavior : MonoBehaviour ...@@ -14,6 +14,7 @@ public class BallBehavior : MonoBehaviour
private GameObject ball; private GameObject ball;
private float ballRadius; private float ballRadius;
private Vector3 ballBottomPos; private Vector3 ballBottomPos;
private Boolean gameOver = false;
// Ground Checks // Ground Checks
[Header("Ground Checks")] [Header("Ground Checks")]
...@@ -36,17 +37,24 @@ public class BallBehavior : MonoBehaviour ...@@ -36,17 +37,24 @@ public class BallBehavior : MonoBehaviour
} }
void Update() void Update()
{
if(!gameOver)
{ {
Vector3 position = transform.position; Vector3 position = transform.position;
float deltaTime = Time.deltaTime; var deltaTime = Time.deltaTime;
position += Vector3.forward * (moveForwardSpeed * deltaTime); position += Vector3.forward * (moveForwardSpeed * deltaTime);
position += Vector3.right * deltaTime * _horizontalAxis; position += Vector3.right * deltaTime * _horizontalAxis;
transform.position = position; transform.position = position;
}
ballBottomPos = ball.transform.position + Vector3.down * ballRadius; ballBottomPos = ball.transform.position + Vector3.down * ballRadius;
if (Physics.CheckSphere(ballBottomPos, groundCheckDistance, groundMask)) isGrounded = Physics.CheckSphere(ballBottomPos, groundCheckDistance, groundMask);
Debug.Log(ball.transform.localPosition.y);
if(ball.transform.position.y < 0.6f && !isGrounded)
{ {
Debug.Log("Grounded"); Debug.Log("Game Over: " + ball.transform.position.y + " " + isGrounded);
gameOver = true;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment