Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
tetra-tower
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Oenos
tetra-tower
Commits
2b006a73
Commit
2b006a73
authored
Jan 30, 2019
by
16도재형
Committed by
18류지석
Jan 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
플랫폼 위에 있을때만 아래로 뛸수있게 함 지석이가 점프해서 달리기 안되게하라고함
parent
417aca7a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
Player.prefab
Assets/Prefabs/Characters/Player.prefab
+5
-2
PlayerController.cs
Assets/Scripts/Characters/PlayerController.cs
+13
-8
No files found.
Assets/Prefabs/Characters/Player.prefab
View file @
2b006a73
...
...
@@ -178,8 +178,8 @@ MonoBehaviour:
m_EditorClassIdentifier
:
rbGravityScale
:
3
rbAttackGravityScale
:
0.5
maxSpeed
:
3
maxDashSpeed
:
6
maxSpeed
:
4
maxDashSpeed
:
7
acceleration
:
20
deceleration
:
20
jumpSpeed
:
11
...
...
@@ -196,6 +196,9 @@ MonoBehaviour:
boxHeight
:
0.3
ropeUp
:
0.6
ropeDown
:
0.8
platformLayer
:
serializedVersion
:
2
m_Bits
:
2048
playerState
:
0
previousState
:
0
---
!u!114
&114402380471012178
...
...
Assets/Scripts/Characters/PlayerController.cs
View file @
2b006a73
...
...
@@ -39,9 +39,10 @@ public class PlayerController : MonoBehaviour
private
float
horizontalRaw
=
0
;
private
float
verticalRaw
=
0
;
private
bool
upKeyDown
=
false
;
private
bool
downKeyDown
=
false
;
private
bool
jump
=
false
;
private
bool
dash
=
false
;
// Variables for
IsGrounded()
// Variables for
collsiion checking
[
SerializeField
]
private
LayerMask
groundLayer
;
[
SerializeField
]
...
...
@@ -50,7 +51,8 @@ public class PlayerController : MonoBehaviour
private
float
boxHeight
;
[
SerializeField
]
private
float
ropeUp
,
ropeDown
;
[
SerializeField
]
private
LayerMask
platformLayer
;
public
PlayerState
playerState
,
previousState
;
...
...
@@ -69,6 +71,7 @@ public class PlayerController : MonoBehaviour
dash
=
Input
.
GetButton
(
"Dash"
);
if
(!
upKeyDown
)
upKeyDown
=
previous
<=
0
&&
verticalRaw
>
0
;
if
(!
downKeyDown
)
downKeyDown
=
previous
>=
0
&&
verticalRaw
<
0
;
if
(
Input
.
GetButtonDown
(
"Jump"
))
{
...
...
@@ -99,11 +102,10 @@ public class PlayerController : MonoBehaviour
}
// Platform downjump
if
(
verticalRaw
<
0
&&
!
isDownPlatform
)
if
(
OnPlatform
()
&&
downKeyDown
)
{
Room
curRoom
=
MapManager
.
mapGrid
[
Player
.
tx
,
Player
.
ty
];
platformCollider
=
curRoom
.
GetComponentInChildren
<
RoomInGame
>().
transform
.
Find
(
"platform"
).
GetComponent
<
CompositeCollider2D
>();
isDownPlatform
=
true
;
StartCoroutine
(
DownPlatform
());
}
if
(
IsInRope
())
...
...
@@ -111,7 +113,7 @@ public class PlayerController : MonoBehaviour
if
(
playerState
==
PlayerState
.
Rope
)
{
// Jump or Horizontal move in rope
if
(
jump
||
(
horizontal
!=
0
&&
verticalRaw
==
0
)
)
if
(
jump
||
horizontal
!=
0
)
{
playerState
=
PlayerState
.
Idle
;
rb
.
gravityScale
=
rbGravityScale
;
...
...
@@ -203,6 +205,7 @@ public class PlayerController : MonoBehaviour
}
upKeyDown
=
false
;
downKeyDown
=
false
;
jump
=
false
;
}
bool
IsGrounded
()
// Is player grounded?
...
...
@@ -221,13 +224,17 @@ public class PlayerController : MonoBehaviour
transform
.
position
+
new
Vector3
(
Player
.
X
/
2f
,
-
ropeDown
,
0
));
return
hit
.
collider
!=
null
;
}
bool
OnPlatform
()
{
RaycastHit2D
hit
=
Physics2D
.
BoxCast
(
transform
.
position
,
new
Vector2
(
Player
.
X
,
boxHeight
),
0
,
Vector2
.
down
,
Player
.
Y
/
2f
,
platformLayer
);
return
hit
.
collider
!=
null
&&
rb
.
velocity
.
y
==
0
;
// 플랫폼 점프 버그 방지
}
public
IEnumerator
DownPlatform
()
{
Physics2D
.
IgnoreCollision
(
platformCollider
,
transform
.
GetComponent
<
Collider2D
>(),
true
);
yield
return
new
WaitForSeconds
(
0.3f
);
while
(
playerState
==
PlayerState
.
Rope
)
yield
return
null
;
Physics2D
.
IgnoreCollision
(
platformCollider
,
transform
.
GetComponent
<
Collider2D
>(),
false
);
isDownPlatform
=
false
;
}
public
IEnumerator
RopeDelay
()
{
...
...
@@ -235,7 +242,5 @@ public class PlayerController : MonoBehaviour
isJumpable
=
true
;
yield
return
new
WaitForSeconds
(
0.3f
);
ropeEnabled
=
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