Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Splashax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sofiane Lasri
Splashax
Commits
f0794950
Commit
f0794950
authored
Mar 9, 2023
by
Sofiane Lasri
Browse files
Options
Downloads
Patches
Plain Diff
isGrounded check
parent
95a93ec0
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Assets/Resources/Prefabs/Platfom.prefab
+1
-1
1 addition, 1 deletion
Assets/Resources/Prefabs/Platfom.prefab
Assets/Scenes/SampleScene.unity
+11
-28
11 additions, 28 deletions
Assets/Scenes/SampleScene.unity
Assets/Scripts/BallBehavior.cs
+15
-7
15 additions, 7 deletions
Assets/Scripts/BallBehavior.cs
with
27 additions
and
36 deletions
Assets/Resources/Prefabs/Platfom.prefab
+
1
−
1
View file @
f0794950
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Assets/Scenes/SampleScene.unity
+
11
−
28
View file @
f0794950
...
@@ -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
.2
5
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
:
1
9.44
value
:
1
3.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
:
1
6.96000
1
value
:
1
1.1
1
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
}
...
...
This diff is collapsed.
Click to expand it.
Assets/Scripts/BallBehavior.cs
+
15
−
7
View file @
f0794950
...
@@ -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
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment