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
46e08797
Commit
46e08797
authored
Mar 27, 2019
by
Unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slider Object Update
parent
472c5783
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
13 deletions
+37
-13
Assets/_Game/Prefabs/Player/Player.prefab
Assets/_Game/Prefabs/Player/Player.prefab
+5
-3
Assets/_Game/Scripts/Elements/SliderObject.cs
Assets/_Game/Scripts/Elements/SliderObject.cs
+17
-1
Assets/_Game/Scripts/Player/MovementController.cs
Assets/_Game/Scripts/Player/MovementController.cs
+15
-9
No files found.
Assets/_Game/Prefabs/Player/Player.prefab
View file @
46e08797
...
...
@@ -108,15 +108,17 @@ MonoBehaviour:
m_Name
:
m_EditorClassIdentifier
:
m_Speed
:
30
m_JumpForce
:
25
0
m_JumpForce
:
1
0
m_MovementSmoothing
:
0.05
m_AirControl
:
1
m_WhatIsGround
:
serializedVersion
:
2
m_Bits
:
512
m_GroundCheck
:
{
fileID
:
52145075018362285
}
m_GroundedRadius
:
0.5
m_GroundedOffset
:
{
x
:
0
,
y
:
-1
}
m_GroundCheckDistance
:
1
m_GroundedRadius
:
0.25
m_GroundedOffset
:
{
x
:
0
,
y
:
0
}
m_GroundMaxSlopeAngle
:
45
m_SecondsWaitToJump
:
0.5
m_MaxJumpCount
:
1
m_fallMultiplier
:
2.5
...
...
Assets/_Game/Scripts/Elements/SliderObject.cs
View file @
46e08797
...
...
@@ -7,7 +7,7 @@ public class SliderObject : MonoBehaviour
private
Rigidbody2D
rb
;
public
float
force
;
private
void
OnTriggerEnter2D
(
Collider2D
collision
)
/*
private void OnTriggerEnter2D(Collider2D collision)
{
if (!GetComponent<Rigidbody2D>())
{
...
...
@@ -27,5 +27,21 @@ public class SliderObject : MonoBehaviour
rb.AddForce(new Vector2(force, 0));
}
}
}*/
private
void
OnCollisionEnter
(
Collision
other
)
{
if
(
other
.
transform
.
gameObject
.
tag
.
Equals
(
"Water"
))
{
gameObject
.
transform
.
SetParent
(
other
.
transform
);
}
}
private
void
OnCollisionExit
(
Collision
other
)
{
if
(
other
.
transform
.
gameObject
.
tag
.
Equals
(
"Water"
))
{
gameObject
.
transform
.
SetParent
(
null
);
}
}
}
Assets/_Game/Scripts/Player/MovementController.cs
View file @
46e08797
...
...
@@ -6,20 +6,23 @@ using UnityEngine.Events;
[
RequireComponent
(
typeof
(
Rigidbody2D
),
typeof
(
BoxCollider2D
))]
public
class
MovementController
:
MonoBehaviour
{
[
Header
(
"Movement"
)]
[
SerializeField
]
private
float
m_Speed
=
10f
;
[
SerializeField
]
private
float
m_JumpForce
=
400f
;
// Amount of force added when the player jumps.
[
SerializeField
]
private
float
m_fallMultiplier
=
2.5f
;
[
SerializeField
]
private
float
m_lowJumpMultiplier
=
2.0f
;
[
Range
(
0
,
.
3f
)]
[
SerializeField
]
private
float
m_MovementSmoothing
=
.
05f
;
// How much to smooth out the movement
[
SerializeField
]
private
bool
m_AirControl
=
false
;
// Whether or not a player can steer while jumping;
[
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
;
[
SerializeField
]
private
Vector2
m_GroundedOffset
=
Vector2
.
zero
;
[
SerializeField
]
private
float
m_GroundMaxSlopeAngle
=
45f
;
[
SerializeField
]
private
float
m_SecondsWaitToJump
=
0.3f
;
[
SerializeField
]
private
int
m_MaxJumpCount
=
1
;
[
SerializeField
]
private
float
m_fallMultiplier
=
2.5f
;
[
SerializeField
]
private
float
m_lowJumpMultiplier
=
2.0f
;
private
bool
m_Grounded
=
false
;
// Whether or not the player is grounded.
private
bool
m_Swimming
=
false
;
...
...
@@ -38,6 +41,8 @@ public class MovementController : MonoBehaviour
//Wird Aktiviert wenn Spieler Landet
public
UnityEvent
OnLandEvent
;
public
UnityEvent
OnSwimEvent
;
public
UnityEvent
OnJumpEvent
;
public
float
GravityModifier
{
...
...
@@ -47,7 +52,11 @@ public class MovementController : MonoBehaviour
public
void
SetSwimming
(
bool
value
)
{
m_Swimming
=
value
;
m_TempJumpCount
=
m_MaxJumpCount
;
if
(
value
)
{
OnSwimEvent
.
Invoke
();
m_TempJumpCount
=
m_MaxJumpCount
;
}
}
private
void
Awake
()
...
...
@@ -60,10 +69,6 @@ public class MovementController : MonoBehaviour
OnLandEvent
=
new
UnityEvent
();
}
private
void
Update
()
{
}
private
void
FixedUpdate
()
{
bool
wasGrounded
=
m_Grounded
;
...
...
@@ -131,6 +136,7 @@ public class MovementController : MonoBehaviour
if
(((
m_Grounded
)
||
(
m_TempJumpCount
>
1
)
||
m_Swimming
)
&&
!
m_Jumped
)
{
// Add a vertical force to the player.
OnJumpEvent
.
Invoke
();
m_Grounded
=
false
;
m_TempJumpCount
--;
//m_Rigidbody2D.AddForce (new Vector2 (0f, m_JumpForce));
...
...
@@ -139,7 +145,7 @@ public class MovementController : MonoBehaviour
}
}
if
(
m_Rigidbody2D
.
velocity
.
y
<
0
)
if
(
m_Rigidbody2D
.
velocity
.
y
<
0
&&
!
m_Swimming
)
{
m_Rigidbody2D
.
velocity
+=
Vector2
.
up
*
Physics2D
.
gravity
.
y
*
(
m_fallMultiplier
-
1
)
*
Time
.
deltaTime
;
}
else
if
(
m_Rigidbody2D
.
velocity
.
y
>
0
&&
!
Input
.
GetButton
(
"Jump"
))
...
...
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