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
388fe66c
Commit
388fe66c
authored
Jun 04, 2015
by
Tim Reiter
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://git.breab.org:2222/gamejam-gpn15/dyingIsMainstream
parents
a5074f8d
b98dc720
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
6 deletions
+25
-6
PlayerControl.cs
Assets/Scripts/PlayerControl.cs
+25
-6
No files found.
Assets/Scripts/PlayerControl.cs
View file @
388fe66c
...
...
@@ -11,6 +11,8 @@ public class PlayerControl : MonoBehaviour
public
float
groundDamping
=
20f
;
// how fast do we change direction? higher means faster
public
float
inAirDamping
=
5f
;
public
float
targetJumpHeight
=
2f
;
public
bool
canDash
=
true
;
public
float
dashCoolDown
=
0.25f
;
// public float jumpWaitTime = 2.0;
[
HideInInspector
]
...
...
@@ -25,7 +27,7 @@ public class PlayerControl : MonoBehaviour
public
Vector3
velocity
;
public
int
playerNumber
=
1
;
//gibt an, ob es sich um player one, player two, etc. handelt. sollte nicht 0 sein;
KeyCode
goRightKeyCode
,
goLeftKeyCode
,
jumpKeyCode
;
KeyCode
goRightKeyCode
,
goLeftKeyCode
,
jumpKeyCode
,
dashKeyCode
;
void
Start
()
{
...
...
@@ -35,10 +37,10 @@ public class PlayerControl : MonoBehaviour
switch
(
playerNumber
)
{
case
1
:
setKeyCodes
(
KeyCode
.
D
,
KeyCode
.
A
,
KeyCode
.
W
);
setKeyCodes
(
KeyCode
.
D
,
KeyCode
.
A
,
KeyCode
.
W
,
KeyCode
.
S
);
break
;
case
2
:
setKeyCodes
(
KeyCode
.
RightArrow
,
KeyCode
.
LeftArrow
,
KeyCode
.
UpArrow
);
setKeyCodes
(
KeyCode
.
RightArrow
,
KeyCode
.
LeftArrow
,
KeyCode
.
UpArrow
,
KeyCode
.
DownArrow
);
break
;
//TODO player 3 and 4
default
:
...
...
@@ -46,11 +48,12 @@ public class PlayerControl : MonoBehaviour
}
}
private
void
setKeyCodes
(
KeyCode
right
,
KeyCode
left
,
KeyCode
up
)
private
void
setKeyCodes
(
KeyCode
right
,
KeyCode
left
,
KeyCode
up
,
KeyCode
dash
)
{
goRightKeyCode
=
right
;
goLeftKeyCode
=
left
;
jumpKeyCode
=
up
;
dashKeyCode
=
dash
;
}
...
...
@@ -97,6 +100,19 @@ public class PlayerControl : MonoBehaviour
//if (_controller.isGrounded)
}
if
(
canDash
&&
Input
.
GetKey
(
dashKeyCode
))
{
float
direction
=
Mathf
.
Sign
(
transform
.
localScale
.
x
);
if
(
normalizedHorizontalSpeed
!=
0
)
{
// player pressed a movement button so prefer the new direction
direction
=
Mathf
.
Sign
(
normalizedHorizontalSpeed
);
}
normalizedHorizontalSpeed
=
5
*
direction
;
canDash
=
false
;
Invoke
(
"EnableDash"
,
dashCoolDown
);
}
if
(
Input
.
GetKeyDown
(
jumpKeyCode
))
{
...
...
@@ -119,4 +135,8 @@ public class PlayerControl : MonoBehaviour
}
}
\ No newline at end of file
void
EnableDash
()
{
canDash
=
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