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
6f542fd8
Commit
6f542fd8
authored
Jun 05, 2015
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make pushing other players work again
Also change push force of player prefabs to 5
parent
068d5b57
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
Player One.prefab
Assets/Resources/Prefabs/Player One.prefab
+0
-0
Player Two.prefab
Assets/Resources/Prefabs/Player Two.prefab
+0
-0
PlayerControl.cs
Assets/Scripts/PlayerControl.cs
+25
-8
No files found.
Assets/Resources/Prefabs/Player One.prefab
View file @
6f542fd8
No preview for this file type
Assets/Resources/Prefabs/Player Two.prefab
View file @
6f542fd8
No preview for this file type
Assets/Scripts/PlayerControl.cs
View file @
6f542fd8
...
...
@@ -16,7 +16,8 @@ public class PlayerControl : MonoBehaviour
public
LayerMask
mask
;
// movement config
public
float
pushForce
=
20f
;
public
float
pushForce
=
5f
;
public
float
pushTime
=
0.5f
;
public
float
gravity
=
-
15f
;
public
float
runSpeed
=
8f
;
public
float
groundDamping
=
20f
;
// how fast do we change direction? higher means faster
...
...
@@ -41,6 +42,11 @@ public class PlayerControl : MonoBehaviour
// public float jumpWaitTime = 2.0;
[
HideInInspector
]
public
Vector2
pushSpeed
=
Vector2
.
zero
;
[
HideInInspector
]
public
float
lastPushStart
=
float
.
NegativeInfinity
;
[
HideInInspector
]
public
float
rawMovementDirection
=
1
;
//[HideInInspector]
public
float
normalizedHorizontalSpeed
=
0
;
...
...
@@ -83,16 +89,21 @@ public class PlayerControl : MonoBehaviour
}
}
void
onControllerCollider
(
RaycastHit2D
hit
)
void
OnCollisionEnter2D
(
Collision2D
coll
)
{
Rigidbody2D
body
=
hit
.
collider
.
gameObject
.
GetComponent
<
Rigidbody2D
>();
if
(
body
)
{
//TODO abfrage " is dashing"
body
.
AddForce
(
move
Direction
*
pushForce
);
if
(
coll
.
collider
.
tag
!=
"Player"
||
!
isDashing
())
return
;
PlayerControl
other
=
coll
.
collider
.
gameObject
.
GetComponent
<
PlayerControl
>();
other
.
setPushSpeed
(
currentDash
Direction
*
pushForce
);
lastDashStart
=
Time
.
time
-
dashCompletionTime
;
currentDashCoolDown
=
dashCollisionCoolDown
;
}
private
void
setPushSpeed
(
Vector2
pushSpeed
)
{
this
.
pushSpeed
=
pushSpeed
;
this
.
lastPushStart
=
Time
.
time
;
}
void
FixedUpdate
()
...
...
@@ -164,9 +175,15 @@ public class PlayerControl : MonoBehaviour
}
}
float
currentPushTime
=
Time
.
time
-
lastPushStart
;
Vector2
currentPushSpeed
=
Vector2
.
zero
;
if
(
0
<=
currentPushTime
&&
currentPushTime
<=
pushTime
)
{
currentPushSpeed
=
Vector2
.
Lerp
(
pushSpeed
,
Vector2
.
zero
,
currentPushTime
/
pushTime
);
}
//finally set the velocity:
body2D
.
velocity
=
velocity
;
body2D
.
velocity
=
velocity
+
currentPushSpeed
;
//update move direction after the currentposition was updated:
moveDirection
=
(
transform
.
position
-
lastPos
).
normalized
;
...
...
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