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
2ca61c5f
Commit
2ca61c5f
authored
Jan 20, 2019
by
18류지석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
플레이어 애니메이터 수정
parent
ac70cdfd
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
201 deletions
+135
-201
Player animator.controller
Assets/Animation/Player animator.controller
+75
-175
PlayScene.unity
Assets/Scenes/PlayScene.unity
+20
-0
PlayerController.cs
Assets/Scripts/Characters/PlayerController.cs
+40
-26
No files found.
Assets/Animation/Player animator.controller
View file @
2ca61c5f
This diff is collapsed.
Click to expand it.
Assets/Scenes/PlayScene.unity
View file @
2ca61c5f
...
...
@@ -677,6 +677,26 @@ Prefab:
propertyPath
:
m_RootOrder
value
:
5
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
114294925164316638
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
propertyPath
:
maxSpeed
value
:
3
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
114294925164316638
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
propertyPath
:
maxDashSpeed
value
:
6
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
61019994424895448
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
propertyPath
:
m_Size.y
value
:
1.5
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
61019994424895448
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
propertyPath
:
m_Offset.y
value
:
-0.09
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
m_IsPrefabAsset
:
0
...
...
Assets/Scripts/Characters/PlayerController.cs
View file @
2ca61c5f
...
...
@@ -56,14 +56,17 @@ public class PlayerController : MonoBehaviour
private
float
rayDistance
;
[
SerializeField
]
private
float
ropeUp
,
ropeDown
;
// Use this for initialization
enum
PlayerState
{
Idle
,
Walk
,
Run
,
GoingUp
,
GoingDown
,
Rope
}
PlayerState
playerState
,
previousState
;
void
Start
()
{
rb
=
gameObject
.
GetComponent
<
Rigidbody2D
>();
anim
=
GetComponent
<
Animator
>();
playerState
=
PlayerState
.
Idle
;
previousState
=
PlayerState
.
Idle
;
}
// Update is called once per frame
void
Update
()
{
horizontal
=
Input
.
GetAxis
(
"Horizontal"
);
...
...
@@ -82,15 +85,6 @@ public class PlayerController : MonoBehaviour
if
(
GameManager
.
gameState
==
GameState
.
Ingame
)
{
anim
.
SetBool
(
"rope"
,
isInRope
);
anim
.
SetBool
(
"run"
,
isDashing
);
anim
.
SetBool
(
"ground"
,
isGrounded
);
anim
.
SetFloat
(
"vspeed"
,
rb
.
velocity
.
y
);
anim
.
SetFloat
(
"speed"
,
Mathf
.
Abs
(
rb
.
velocity
.
x
));
if
(
isGrounded
||
isInRope
)
{
anim
.
SetBool
(
"jump"
,
false
);
}
if
(
isGrounded
)
isJumpable
=
true
;
...
...
@@ -114,11 +108,11 @@ public class PlayerController : MonoBehaviour
}
if
(
IsInRope
())
{
if
(
isIn
Rope
)
if
(
playerState
==
PlayerState
.
Rope
)
{
if
(
horizontalRaw
!=
0f
&&
verticalRaw
==
0f
)
{
isInRope
=
fals
e
;
playerState
=
PlayerState
.
Idl
e
;
rb
.
gravityScale
=
2f
;
StartCoroutine
(
RopeDelay
());
...
...
@@ -128,19 +122,20 @@ public class PlayerController : MonoBehaviour
}
else
if
(
verticalRaw
!=
0
&&
ropeEnabled
&&
horizontalRaw
==
0
)
{
isInRope
=
tru
e
;
playerState
=
PlayerState
.
Rop
e
;
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
);
}
}
anim
.
SetFloat
(
"ropeUpDown"
,
verticalRaw
);
}
else
{
isInRope
=
fals
e
;
playerState
=
PlayerState
.
Idl
e
;
rb
.
gravityScale
=
2f
;
}
if
(
!
isIn
Rope
)
if
(
playerState
!=
PlayerState
.
Rope
)
{
float
vertical
=
rb
.
velocity
.
y
;
if
(
jump
)
...
...
@@ -148,20 +143,20 @@ public class PlayerController : MonoBehaviour
if
(
isGrounded
)
{
vertical
=
jumpSpeed
;
anim
.
SetBool
(
"jump"
,
true
);
}
else
if
(
isJumpable
)
{
vertical
=
doubleJumpSpeed
;
anim
.
SetBool
(
"jump"
,
true
);
isJumpable
=
false
;
}
}
if
(!
isGrounded
)
{
if
(
vertical
>
0
)
playerState
=
PlayerState
.
GoingUp
;
else
playerState
=
PlayerState
.
GoingDown
;
}
//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
)
...
...
@@ -192,6 +187,15 @@ public class PlayerController : MonoBehaviour
else
rb
.
AddForce
(
horizontalRaw
*
accerlation
*
Time
.
smoothDeltaTime
*
Vector2
.
right
);
if
(
isGrounded
)
{
if
(
horizontalRaw
==
0
)
playerState
=
PlayerState
.
Idle
;
else
{
if
(
isDashing
)
playerState
=
PlayerState
.
Run
;
else
playerState
=
PlayerState
.
Walk
;
}
}
if
(((
horizontalRaw
==
0
)
||
(
rb
.
velocity
.
x
>
0
&&
horizontalRaw
<
0
)
||
(
rb
.
velocity
.
x
<
0
&&
horizontalRaw
>
0
))
&&
(
isGrounded
))
{
...
...
@@ -202,7 +206,17 @@ public class PlayerController : MonoBehaviour
else
rb
.
velocity
=
new
Vector2
(
Mathf
.
Clamp
(
rb
.
velocity
.
x
,
-
maxSpeed
,
maxSpeed
),
vertical
);
}
if
(
previousState
!=
playerState
)
switch
(
playerState
)
{
case
PlayerState
.
Idle
:
anim
.
SetTrigger
(
"idle"
);
break
;
case
PlayerState
.
Walk
:
anim
.
SetTrigger
(
"walk"
);
break
;
case
PlayerState
.
Run
:
anim
.
SetTrigger
(
"run"
);
break
;
case
PlayerState
.
GoingUp
:
anim
.
SetTrigger
(
"upTrigger"
);
break
;
case
PlayerState
.
GoingDown
:
anim
.
SetTrigger
(
"downTrigger"
);
break
;
case
PlayerState
.
Rope
:
anim
.
SetTrigger
(
"rope"
);
break
;
}
previousState
=
playerState
;
}
jump
=
false
;
}
...
...
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