Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Suck It
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GameDevWeek
W
Wintersemester 2018-2019
Unity
Suck It
Commits
d6fb3255
Commit
d6fb3255
authored
Mar 28, 2019
by
Unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Movement Controller sollte nicht mehr an Wänden Hängen bleiben
parent
7cf6460a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
23 deletions
+33
-23
Assets/_Game/Prefabs/Player/Player.prefab
Assets/_Game/Prefabs/Player/Player.prefab
+18
-17
Assets/_Game/Scripts/Player/MovementController.cs
Assets/_Game/Scripts/Player/MovementController.cs
+15
-6
No files found.
Assets/_Game/Prefabs/Player/Player.prefab
View file @
d6fb3255
...
...
@@ -13,12 +13,12 @@ GameObject:
-
component
:
{
fileID
:
2055293003418080559
}
-
component
:
{
fileID
:
52145075018362291
}
-
component
:
{
fileID
:
52145075018362284
}
-
component
:
{
fileID
:
779623631694574805
}
-
component
:
{
fileID
:
352228602
}
-
component
:
{
fileID
:
352228603
}
-
component
:
{
fileID
:
352228604
}
-
component
:
{
fileID
:
352228605
}
-
component
:
{
fileID
:
352228606
}
-
component
:
{
fileID
:
2596175625849265254
}
m_Layer
:
10
m_Name
:
Player
m_TagString
:
Player
...
...
@@ -112,6 +112,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
e310ba2b65602490894409ff217e2731
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
r_State
:
{
fileID
:
0
}
m_Speed
:
30
m_JumpForce
:
10
m_fallMultiplier
:
2.5
...
...
@@ -164,22 +165,6 @@ Rigidbody2D:
m_SleepingMode
:
1
m_CollisionDetection
:
1
m_Constraints
:
4
---
!u!70
&779623631694574805
CapsuleCollider2D
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
52145075018362288
}
m_Enabled
:
1
m_Density
:
1
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_UsedByEffector
:
0
m_UsedByComposite
:
0
m_Offset
:
{
x
:
-0.03
,
y
:
-0.36
}
m_Size
:
{
x
:
1.05
,
y
:
1.39
}
m_Direction
:
0
---
!u!114
&352228602
MonoBehaviour
:
m_ObjectHideFlags
:
0
...
...
@@ -260,3 +245,19 @@ MonoBehaviour:
Cooldown
:
0
attackRange
:
0
firePower
:
0
---
!u!70
&2596175625849265254
CapsuleCollider2D
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
52145075018362288
}
m_Enabled
:
1
m_Density
:
1
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_UsedByEffector
:
0
m_UsedByComposite
:
0
m_Offset
:
{
x
:
-0.05
,
y
:
-0.3
}
m_Size
:
{
x
:
1.06
,
y
:
1.46
}
m_Direction
:
0
Assets/_Game/Scripts/Player/MovementController.cs
View file @
d6fb3255
...
...
@@ -17,9 +17,8 @@ public class MovementController : MonoBehaviour
[
SerializeField
]
private
bool
m_AirControl
=
false
;
// Whether or not a player can steer while jumping;
[
SerializeField
]
private
bool
m_CanSwim
=
true
;
[
Header
(
"Ground Check Control"
)]
[
SerializeField
]
private
LayerMask
m_WhatIsGround
;
// A mask determining what is ground to the character
[
Header
(
"Ground Check Control"
)]
[
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_GroundCheckDistance
=
1.5f
;
[
SerializeField
]
private
float
m_GroundedRadius
=
.
2f
;
...
...
@@ -52,7 +51,7 @@ public class MovementController : MonoBehaviour
public
void
SetMovementParameters
(
MovementState
state
)
{
m_JumpForce
=
state
.
jumpForce
;
//
m_MovementSmoothing = state.smoothing;
m_MovementSmoothing
=
state
.
smoothing
;
m_AirControl
=
state
.
airControl
;
m_CanSwim
=
state
.
canSwim
;
m_Speed
=
state
.
moveSpeed
;
...
...
@@ -110,9 +109,9 @@ public class MovementController : MonoBehaviour
public
void
Move
(
Vector2
move
,
bool
jump
)
{
//Debug.Log(m_Swimming);
//only control the player if grounded or airControl is turned on
if
(
m_Grounded
||
m_AirControl
||
(
m_Swimming
&&
m_CanSwim
))
if
(
m_Grounded
||
(
m_AirControl
&&
(
m_Airborn
&&
!
m_Grounded
))
||
(
m_Swimming
&&
m_CanSwim
))
{
// Move the character by finding the target velocity
Vector2
targetVelocity
=
new
Vector2
((
move
.
x
*
m_Speed
*
Time
.
deltaTime
)
*
10f
,
m_Rigidbody2D
.
velocity
.
y
);
...
...
@@ -203,6 +202,16 @@ public class MovementController : MonoBehaviour
transform
.
localScale
=
theScale
;
}
private
void
OnCollisionEnter2D
(
Collision2D
other
)
{
m_Airborn
=
false
;
}
private
void
OnCollisionExit2D
(
Collision2D
other
)
{
m_Airborn
=
true
;
}
void
OnDrawGizmos
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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