Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dyingIsMainstream
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gamejam-gpn15
dyingIsMainstream
Commits
e4bd7224
Commit
e4bd7224
authored
Jun 05, 2015
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store dash direction as Vector2
parent
d18a8444
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
PlayerControl.cs
Assets/Scripts/PlayerControl.cs
+22
-12
No files found.
Assets/Scripts/PlayerControl.cs
View file @
e4bd7224
...
@@ -14,9 +14,9 @@ public class PlayerControl : MonoBehaviour
...
@@ -14,9 +14,9 @@ public class PlayerControl : MonoBehaviour
public
float
targetJumpHeight
=
2f
;
public
float
targetJumpHeight
=
2f
;
public
float
lastDashStart
=
float
.
NegativeInfinity
;
public
float
lastDashStart
=
float
.
NegativeInfinity
;
[
HideInInspector
]
[
HideInInspector
]
public
float
currentDashDirection
=
0.0f
;
public
Vector2
dashDirection
=
Vector2
.
right
;
[
HideInInspector
]
[
HideInInspector
]
public
float
dashDirection
=
1.0f
;
public
Vector2
currentDashDirection
=
Vector2
.
right
;
public
float
dashCompletionTime
=
0.25f
;
public
float
dashCompletionTime
=
0.25f
;
public
float
dashStartSpeed
=
20.0f
;
public
float
dashStartSpeed
=
20.0f
;
public
float
dashEndSpeed
=
8.0f
;
public
float
dashEndSpeed
=
8.0f
;
...
@@ -93,14 +93,7 @@ public class PlayerControl : MonoBehaviour
...
@@ -93,14 +93,7 @@ public class PlayerControl : MonoBehaviour
if
(
_controller
.
isGrounded
)
if
(
_controller
.
isGrounded
)
velocity
.
y
=
0
;
velocity
.
y
=
0
;
if
(
Input
.
GetKey
(
goRightKeyCode
))
updateDashDirection
();
{
dashDirection
=
1.0f
;
}
else
if
(
Input
.
GetKey
(
goLeftKeyCode
))
{
dashDirection
=
-
1.0f
;
}
if
(
canDash
()
&&
Input
.
GetKey
(
dashKeyCode
))
if
(
canDash
()
&&
Input
.
GetKey
(
dashKeyCode
))
{
{
...
@@ -111,8 +104,7 @@ public class PlayerControl : MonoBehaviour
...
@@ -111,8 +104,7 @@ public class PlayerControl : MonoBehaviour
if
(
isDashing
())
if
(
isDashing
())
{
{
velocity
.
x
=
Mathf
.
Lerp
(
currentDashDirection
*
dashStartSpeed
,
currentDashDirection
*
dashEndSpeed
,
getDashTime
()
/
dashCompletionTime
);
velocity
=
currentDashDirection
*
Mathf
.
Lerp
(
dashStartSpeed
,
dashEndSpeed
,
getDashTime
()
/
dashCompletionTime
);
velocity
.
y
=
0
;
}
}
else
else
{
{
...
@@ -171,6 +163,24 @@ public class PlayerControl : MonoBehaviour
...
@@ -171,6 +163,24 @@ public class PlayerControl : MonoBehaviour
_controller
.
move
(
velocity
*
Time
.
deltaTime
);
_controller
.
move
(
velocity
*
Time
.
deltaTime
);
}
}
private
void
updateDashDirection
()
{
float
horizontalDashDirection
=
0.0f
;
if
(
Input
.
GetKey
(
goRightKeyCode
))
{
horizontalDashDirection
=
1.0f
;
}
else
if
(
Input
.
GetKey
(
goLeftKeyCode
))
{
horizontalDashDirection
=
-
1.0f
;
}
float
verticalDashDirection
=
0.0f
;
if
(
horizontalDashDirection
!=
0.0f
||
verticalDashDirection
!=
0.0f
)
dashDirection
=
new
Vector2
(
horizontalDashDirection
,
verticalDashDirection
);
}
private
float
getDashTime
()
private
float
getDashTime
()
{
{
return
Time
.
time
-
lastDashStart
;
return
Time
.
time
-
lastDashStart
;
...
...
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