Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Wintersemester 2018-2019
Unity
Suck It
Commits
d7a682f9
Commit
d7a682f9
authored
Mar 26, 2019
by
Unknown
Browse files
kurze Verbesserung des Movement Controller
parent
494f82df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Assets/_Game/Scripts/Interaction.meta
deleted
100644 → 0
View file @
494f82df
fileFormatVersion: 2
guid: 5782222d4c9b9424ea96676650e643a8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/_Game/Scripts/Player/MovementController.cs
View file @
d7a682f9
...
...
@@ -12,9 +12,10 @@ public class MovementController : MonoBehaviour {
[
SerializeField
]
private
bool
m_AirControl
=
false
;
// Whether or not a player can steer while jumping;
[
SerializeField
]
private
LayerMask
m_WhatIsGround
;
// A mask determining what is ground to the character
[
SerializeField
]
private
Transform
m_GroundCheck
;
// A position marking where to check if the player is grounded.
[
SerializeField
]
private
float
m_GroundedRadius
=
.
2f
;
[
SerializeField
]
private
Vector2
m_GroundedOffset
=
Vector2
.
zero
;
[
SerializeField
]
private
int
m_MaxJumpCount
=
1
;
const
float
k_GroundedRadius
=
.
2f
;
// Radius of the overlap circle to determine if grounded
private
bool
m_Grounded
;
// Whether or not the player is grounded.
private
bool
m_Airborn
;
private
Rigidbody2D
m_Rigidbody2D
;
...
...
@@ -45,7 +46,8 @@ public class MovementController : MonoBehaviour {
// The player is grounded if a circlecast to the groundcheck position hits anything designated as ground
// This can be done using layers instead but Sample Assets will not overwrite your project settings.
Collider2D
[]
colliders
=
Physics2D
.
OverlapCircleAll
(
m_GroundCheck
.
position
,
k_GroundedRadius
,
m_WhatIsGround
);
Vector3
pos
=
m_GroundCheck
.
position
+
new
Vector3
(
m_GroundedOffset
.
x
,
m_GroundedOffset
.
y
);
Collider2D
[]
colliders
=
Physics2D
.
OverlapCircleAll
(
pos
,
m_GroundedRadius
,
m_WhatIsGround
);
for
(
int
i
=
0
;
i
<
colliders
.
Length
;
i
++)
{
if
(
colliders
[
i
].
gameObject
!=
gameObject
)
{
m_Grounded
=
true
;
...
...
@@ -103,7 +105,7 @@ public class MovementController : MonoBehaviour {
void
OnDrawGizmos
()
{
Gizmos
.
color
=
Color
.
green
;
Gizmos
.
DrawWireSphere
(
m_GroundCheck
.
position
,
k
_GroundedRadius
);
Gizmos
.
DrawWireSphere
(
m_GroundCheck
.
position
+
new
Vector3
(
m_GroundedOffset
.
x
,
m_GroundedOffset
.
y
,
0
),
m
_GroundedRadius
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment