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
5e04126a
Commit
5e04126a
authored
6 years ago
by
abpo11
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
마찰 방식 수정, 벽과 플레이어 사이의 마찰 없앰, 로프 버그 수정, 화면 전환시 플레이어 조작 x, 조작감 개선
parent
0688c38f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
83 deletions
+111
-83
nofriction.physicsMaterial2D
Assets/Prefabs/Characters/nofriction.physicsMaterial2D
+10
-0
nofriction.physicsMaterial2D.meta
Assets/Prefabs/Characters/nofriction.physicsMaterial2D.meta
+8
-0
PlayScene.unity
Assets/Scenes/PlayScene.unity
+3
-3
PlayerController.cs
Assets/Scripts/Characters/PlayerController.cs
+90
-80
No files found.
Assets/Prefabs/Characters/nofriction.physicsMaterial2D
0 → 100644
View file @
5e04126a
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!62
&6200000
PhysicsMaterial2D
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
m_Name
:
nofriction
friction
:
0
bounciness
:
0
This diff is collapsed.
Click to expand it.
Assets/Prefabs/Characters/nofriction.physicsMaterial2D.meta
0 → 100644
View file @
5e04126a
fileFormatVersion: 2
guid: 90e689a435f304c469db49daef28ed89
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 6200000
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
Click to expand it.
Assets/Scenes/PlayScene.unity
View file @
5e04126a
...
...
@@ -255,11 +255,11 @@ MonoBehaviour:
m_EditorClassIdentifier
:
maxSpeed
:
5
maxDashSpeed
:
10
accerlation
:
6
00
accerlation
:
12
00
jumpSpeed
:
10
ropeSpeed
:
3
doubleJumpSpeed
:
10
dashAccerlation
:
1
000
dashAccerlation
:
2
000
isDashing
:
0
platformArray
:
[]
horizontal
:
0
...
...
@@ -348,7 +348,7 @@ BoxCollider2D:
m_GameObject
:
{
fileID
:
489222433
}
m_Enabled
:
1
m_Density
:
1
m_Material
:
{
fileID
:
0
}
m_Material
:
{
fileID
:
6200000
,
guid
:
90e689a435f304c469db49daef28ed89
,
type
:
2
}
m_IsTrigger
:
0
m_UsedByEffector
:
0
m_UsedByComposite
:
0
...
...
This diff is collapsed.
Click to expand it.
Assets/Scripts/Characters/PlayerController.cs
View file @
5e04126a
...
...
@@ -77,59 +77,20 @@ public class PlayerController : MonoBehaviour
private
void
FixedUpdate
()
{
isGrounded
=
IsGrounded
();
if
(
isGrounded
)
isJumpable
=
true
;
if
(
isGrounded
)
{
if
(
horizontalRaw
==
1f
)
transform
.
localScale
=
new
Vector3
(
1f
,
transform
.
localScale
.
y
,
transform
.
localScale
.
z
);
else
if
(
horizontalRaw
==
-
1f
)
transform
.
localScale
=
new
Vector3
(-
1f
,
transform
.
localScale
.
y
,
transform
.
localScale
.
z
);
}
if
(
IsInRope
())
if
(
GameManager
.
gameState
==
GameManager
.
GameState
.
Ingame
)
{
if
(
isInRope
)
{
if
(
horizontalRaw
!=
0f
&&
verticalRaw
==
0f
)
{
isInRope
=
false
;
rb
.
gravityScale
=
2f
;
StartCoroutine
(
RopeDelay
());
}
rb
.
velocity
=
new
Vector2
(
0f
,
verticalRaw
*
ropeSpeed
);
}
else
if
(
verticalRaw
!=
0
&&
ropeEnabled
&&
horizontalRaw
==
0
)
if
(
isGrounded
)
isJumpable
=
true
;
if
(
isGrounded
)
{
isInRope
=
true
;
rb
.
gravityScale
=
0f
;
transform
.
position
=
new
Vector2
(
Mathf
.
Round
(
transform
.
position
.
x
-
0.5f
)
+
0.5f
,
transform
.
position
.
y
);
rb
.
velocity
=
new
Vector2
(
0f
,
0f
);
if
(
horizontalRaw
==
1f
)
transform
.
localScale
=
new
Vector3
(
1f
,
transform
.
localScale
.
y
,
transform
.
localScale
.
z
);
else
if
(
horizontalRaw
==
-
1f
)
transform
.
localScale
=
new
Vector3
(-
1f
,
transform
.
localScale
.
y
,
transform
.
localScale
.
z
);
}
}
else
{
isInRope
=
false
;
rb
.
gravityScale
=
2f
;
}
if
(!
isInRope
)
{
float
vertical
=
rb
.
velocity
.
y
;
if
(
jump
)
{
if
(
isGrounded
)
{
vertical
=
jumpSpeed
;
}
else
if
(
isJumpable
)
{
vertical
=
doubleJumpSpeed
;
isJumpable
=
false
;
}
}
if
(
verticalRaw
==
-
1
&&
!
isDownPlatform
)
if
(
verticalRaw
==
-
1
&&
!
isDownPlatform
)
{
RaycastHit2D
hit
=
Physics2D
.
Raycast
(
transform
.
position
,
Vector2
.
down
,
rayDistance
,
platformLayer
);
if
(
hit
.
collider
!=
null
&&
rb
.
velocity
.
y
==
0
)
...
...
@@ -140,48 +101,95 @@ public class PlayerController : MonoBehaviour
StartCoroutine
(
DownPlatform
());
}
}
if
(
IsInRope
())
{
if
(
isInRope
)
{
if
(
horizontalRaw
!=
0f
&&
verticalRaw
==
0f
)
{
isInRope
=
false
;
rb
.
gravityScale
=
2f
;
StartCoroutine
(
RopeDelay
());
//rb.velocity = new Vector2(horizontal * speed * Time.smoothDeltaTime, vertical);
// rb.velocity = new Vector2(rb.velocity.x, vertical
);
}
rb
.
velocity
=
new
Vector2
(
0f
,
verticalRaw
*
ropeSpeed
);
if
(
horizontalRaw
!=
0
)
{
if
(
horizontal
!=
1
&&
horizontal
!=
-
1
&&
dashStart
==
0
)
}
else
if
(
verticalRaw
!=
0
&&
ropeEnabled
&&
horizontalRaw
==
0
)
{
//짧게 눌렀을 때
dashStart
=
1
;
isInRope
=
true
;
rb
.
gravityScale
=
0f
;
transform
.
position
=
new
Vector2
(
Mathf
.
Round
(
transform
.
position
.
x
-
0.5f
)
+
0.5f
,
transform
.
position
.
y
);
rb
.
velocity
=
new
Vector2
(
0f
,
0f
);
}
}
if
(
horizontalRaw
==
0
&&
horizontal
!=
0
&&
dashStart
==
1
)
{
//방금 뗐을때
dashStart
=
2
;
//이제 빠르게 켜면 됨
}
if
(
dashStart
==
2
&&
horizontalRaw
!=
0
)
else
{
isDashing
=
true
;
isInRope
=
false
;
rb
.
gravityScale
=
2f
;
}
if
(
horizontalRaw
==
0
&&
horizontal
==
0
)
if
(!
isInRope
)
{
dashStart
=
0
;
isDashing
=
false
;
}
if
(
isDashing
)
rb
.
AddForce
(
horizontalRaw
*
dashAccerlation
*
Time
.
smoothDeltaTime
*
Vector2
.
right
);
else
rb
.
AddForce
(
horizontalRaw
*
accerlation
*
Time
.
smoothDeltaTime
*
Vector2
.
right
);
float
vertical
=
rb
.
velocity
.
y
;
if
(
jump
)
{
if
(
isGrounded
)
{
vertical
=
jumpSpeed
;
}
else
if
(
isJumpable
)
{
vertical
=
doubleJumpSpeed
;
isJumpable
=
false
;
}
}
if
(((
horizontalRaw
==
0
)
||
(
rb
.
velocity
.
x
>
0
&&
horizontalRaw
<
0
)
||
(
rb
.
velocity
.
x
<
0
&&
horizontalRaw
>
0
))
&&
(
isGrounded
))
{
rb
.
AddForce
(
rb
.
velocity
.
x
*
(-
10f
)
*
Vector2
.
right
*
Time
.
smoothDeltaTime
);
//rb.velocity = new Vector2(horizontal * speed * Time.smoothDeltaTime, vertical);
// rb.velocity = new Vector2(rb.velocity.x, vertical);
if
(
horizontalRaw
!=
0
)
{
if
(
horizontal
!=
1
&&
horizontal
!=
-
1
&&
dashStart
==
0
)
{
//짧게 눌렀을 때
dashStart
=
1
;
}
}
if
(
horizontalRaw
==
0
&&
horizontal
!=
0
&&
dashStart
==
1
)
{
//방금 뗐을때
dashStart
=
2
;
//이제 빠르게 켜면 됨
}
if
(
dashStart
==
2
&&
horizontalRaw
!=
0
)
{
isDashing
=
true
;
}
if
(
horizontalRaw
==
0
&&
horizontal
==
0
)
{
dashStart
=
0
;
isDashing
=
false
;
}
if
(
isDashing
)
rb
.
AddForce
(
horizontalRaw
*
dashAccerlation
*
Time
.
smoothDeltaTime
*
Vector2
.
right
);
else
rb
.
AddForce
(
horizontalRaw
*
accerlation
*
Time
.
smoothDeltaTime
*
Vector2
.
right
);
if
(((
horizontalRaw
==
0
)
||
(
rb
.
velocity
.
x
>
0
&&
horizontalRaw
<
0
)
||
(
rb
.
velocity
.
x
<
0
&&
horizontalRaw
>
0
))
&&
(
isGrounded
))
{
// rb.AddForce(rb.velocity.x * (-100f) * Vector2.right * Time.smoothDeltaTime);
rb
.
velocity
=
new
Vector2
(
rb
.
velocity
.
x
/
(
1.5f
),
rb
.
velocity
.
y
);
}
if
(
isDashing
)
rb
.
velocity
=
new
Vector2
(
Mathf
.
Clamp
(
rb
.
velocity
.
x
,
-
maxDashSpeed
,
maxDashSpeed
),
vertical
);
else
rb
.
velocity
=
new
Vector2
(
Mathf
.
Clamp
(
rb
.
velocity
.
x
,
-
maxSpeed
,
maxSpeed
),
vertical
);
}
if
(
isDashing
)
rb
.
velocity
=
new
Vector2
(
Mathf
.
Clamp
(
rb
.
velocity
.
x
,
-
maxDashSpeed
,
maxDashSpeed
),
vertical
);
else
rb
.
velocity
=
new
Vector2
(
Mathf
.
Clamp
(
rb
.
velocity
.
x
,
-
maxSpeed
,
maxSpeed
),
vertical
);
}
jump
=
false
;
}
...
...
@@ -213,6 +221,7 @@ public class PlayerController : MonoBehaviour
{
element
.
enabled
=
false
;
yield
return
new
WaitForSeconds
(
0.3f
);
while
(
isInRope
)
yield
return
new
WaitForSeconds
(
0.1f
);
element
.
enabled
=
true
;
isDownPlatform
=
false
;
}
...
...
@@ -224,6 +233,7 @@ public class PlayerController : MonoBehaviour
isJumpable
=
true
;
yield
return
new
WaitForSeconds
(
0.5f
);
ropeEnabled
=
true
;
}
}
This diff is collapsed.
Click to expand it.
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