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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
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
+28
-11
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
...
@@ -16,7 +16,8 @@ public class PlayerControl : MonoBehaviour
public
LayerMask
mask
;
public
LayerMask
mask
;
// movement config
// movement config
public
float
pushForce
=
20f
;
public
float
pushForce
=
5f
;
public
float
pushTime
=
0.5f
;
public
float
gravity
=
-
15f
;
public
float
gravity
=
-
15f
;
public
float
runSpeed
=
8f
;
public
float
runSpeed
=
8f
;
public
float
groundDamping
=
20f
;
// how fast do we change direction? higher means faster
public
float
groundDamping
=
20f
;
// how fast do we change direction? higher means faster
...
@@ -41,6 +42,11 @@ public class PlayerControl : MonoBehaviour
...
@@ -41,6 +42,11 @@ public class PlayerControl : MonoBehaviour
// public float jumpWaitTime = 2.0;
// public float jumpWaitTime = 2.0;
[
HideInInspector
]
[
HideInInspector
]
public
Vector2
pushSpeed
=
Vector2
.
zero
;
[
HideInInspector
]
public
float
lastPushStart
=
float
.
NegativeInfinity
;
[
HideInInspector
]
public
float
rawMovementDirection
=
1
;
public
float
rawMovementDirection
=
1
;
//[HideInInspector]
//[HideInInspector]
public
float
normalizedHorizontalSpeed
=
0
;
public
float
normalizedHorizontalSpeed
=
0
;
...
@@ -83,16 +89,21 @@ public class PlayerControl : MonoBehaviour
...
@@ -83,16 +89,21 @@ public class PlayerControl : MonoBehaviour
}
}
}
}
void
onControllerCollider
(
RaycastHit2D
hit
)
void
OnCollisionEnter2D
(
Collision2D
coll
)
{
{
Rigidbody2D
body
=
hit
.
collider
.
gameObject
.
GetComponent
<
Rigidbody2D
>();
if
(
coll
.
collider
.
tag
!=
"Player"
||
!
isDashing
())
if
(
body
)
return
;
{
//TODO abfrage " is dashing"
PlayerControl
other
=
coll
.
collider
.
gameObject
.
GetComponent
<
PlayerControl
>();
body
.
AddForce
(
moveDirection
*
pushForce
);
other
.
setPushSpeed
(
currentDashDirection
*
pushForce
);
lastDashStart
=
Time
.
time
-
dashCompletionTime
;
lastDashStart
=
Time
.
time
-
dashCompletionTime
;
currentDashCoolDown
=
dashCollisionCoolDown
;
currentDashCoolDown
=
dashCollisionCoolDown
;
}
}
private
void
setPushSpeed
(
Vector2
pushSpeed
)
{
this
.
pushSpeed
=
pushSpeed
;
this
.
lastPushStart
=
Time
.
time
;
}
}
void
FixedUpdate
()
void
FixedUpdate
()
...
@@ -164,9 +175,15 @@ public class PlayerControl : MonoBehaviour
...
@@ -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:
//finally set the velocity:
body2D
.
velocity
=
velocity
;
body2D
.
velocity
=
velocity
+
currentPushSpeed
;
//update move direction after the currentposition was updated:
//update move direction after the currentposition was updated:
moveDirection
=
(
transform
.
position
-
lastPos
).
normalized
;
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