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
72d47e84
Commit
72d47e84
authored
Mar 28, 2019
by
mthiele2
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.fsi.hochschule-trier.de/GameDevWeek/ws-18_19/unity/suck-it
parents
b5a9331b
62e2b8e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
14 deletions
+27
-14
Assets/_Game/Scripts/Level Hazards/MovingPlattform.cs
Assets/_Game/Scripts/Level Hazards/MovingPlattform.cs
+23
-12
Assets/_Game/Scripts/Player/MovementController.cs
Assets/_Game/Scripts/Player/MovementController.cs
+4
-2
No files found.
Assets/_Game/Scripts/Level Hazards/MovingPlattform.cs
View file @
72d47e84
...
...
@@ -6,6 +6,7 @@ using UnityEngine;
public
class
MovingPlattform
:
MonoBehaviour
{
public
List
<
Vector2
>
m_Points
;
public
List
<
string
>
m_Tags
;
[
SerializeField
]
private
float
m_Speed
=
0.3f
;
//plattform geschwindigkeit
[
SerializeField
]
private
float
m_Wait
=
2f
;
//zeit in Sekunden wie lange die Plattform wartet
[
SerializeField
]
private
int
m_StartIndex
=
0
;
//Index in der Liste an der die Plattform starten soll
...
...
@@ -94,21 +95,31 @@ public class MovingPlattform : MonoBehaviour {
}
//CollisionEnter mit Spieler kann um Gegner erweitert werden
void
OnCollisionEnter2D
(
Collision2D
col2D
)
{
if
(
col2D
.
transform
.
gameObject
.
tag
.
Equals
(
"Player"
))
{
//Setzt parent object des Spielers zu dieser Plattform somit wird die transformation der Plattform auf den Spieler Übertragen
col2D
.
transform
.
SetParent
(
gameObject
.
transform
);
if
(
m_MoveingByTouching
)
Patrol
();
}
void
OnCollisionEnter2D
(
Collision2D
col2D
)
{
for
(
int
i
=
0
;
i
<
m_Tags
.
Count
;
i
++)
{
if
(
col2D
.
gameObject
.
tag
.
Equals
(
m_Tags
[
i
])
||
col2D
.
gameObject
.
tag
.
Equals
(
"Player"
))
{
//Setzt parent object des Spielers zu dieser Plattform somit wird die transformation der Plattform auf den Spieler Übertragen
col2D
.
transform
.
SetParent
(
gameObject
.
transform
);
if
(
m_MoveingByTouching
)
Patrol
();
}
}
}
//CollisionExit mit Spieler kann um Gegner erweitert werden
void
OnCollisionExit2D
(
Collision2D
col2D
)
{
if
(
col2D
.
transform
.
gameObject
.
tag
.
Equals
(
"Player"
))
{
//Sets Spieler Parent zu niemand
col2D
.
transform
.
SetParent
(
null
);
}
for
(
int
i
=
0
;
i
<
m_Tags
.
Count
;
i
++)
{
if
(
col2D
.
gameObject
.
tag
.
Equals
(
m_Tags
[
i
])
||
col2D
.
gameObject
.
tag
.
Equals
(
"Player"
))
{
//Sets Spieler Parent zu niemand
col2D
.
transform
.
SetParent
(
null
);
}
}
}
void
OnDrawGizmosSelected
()
{
...
...
@@ -128,4 +139,4 @@ public class MovingPlattform : MonoBehaviour {
}
}
}
}
\ No newline at end of file
}
Assets/_Game/Scripts/Player/MovementController.cs
View file @
72d47e84
...
...
@@ -141,16 +141,16 @@ public class MovementController : MonoBehaviour
if
(((
m_Grounded
)
||
(
m_TempJumpCount
>
1
)
||
(
m_Swimming
&&
m_CanSwim
))
&&
!
m_Jumped
)
{
// Add a vertical force to the player.
OnJumpEvent
.
Invoke
();
m_Grounded
=
false
;
m_TempJumpCount
--;
//m_Rigidbody2D.AddForce (new Vector2 (0f, m_JumpForce));
m_Rigidbody2D
.
velocity
=
Vector2
.
up
*
m_JumpForce
;
OnJumpEvent
.
Invoke
();
StartCoroutine
(
Wait
(
m_SecondsWaitToJump
));
}
}
if
(
m_Rigidbody2D
.
velocity
.
y
<
0
&&
!
m_Swimming
)
if
(
m_Rigidbody2D
.
velocity
.
y
<
0
&&
!
m_Swimming
&&
!
m_Grounded
)
{
m_Rigidbody2D
.
velocity
+=
Vector2
.
up
*
Physics2D
.
gravity
.
y
*
(
m_fallMultiplier
-
1
)
*
Time
.
deltaTime
;
}
...
...
@@ -205,11 +205,13 @@ public class MovementController : MonoBehaviour
private
void
OnCollisionEnter2D
(
Collision2D
other
)
{
if
(
other
.
gameObject
.
layer
==
m_WhatIsGround
)
m_Airborn
=
false
;
}
private
void
OnCollisionExit2D
(
Collision2D
other
)
{
if
(
other
.
gameObject
.
layer
==
m_WhatIsGround
)
m_Airborn
=
true
;
}
...
...
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