Skip to content
Snippets Groups Projects
Commit 206ae4c2 authored by clg544's avatar clg544
Browse files

Fixed compiler error, squared distance in tension equation to add responsiveness of tether.

parent 36b3d845
No related branches found
No related tags found
2 merge requests!8Develop,!3Feature physics
......@@ -656,6 +656,16 @@ Prefab:
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114537395268845308, guid: f5beac725b81ce84e9335ad6d595f36f,
type: 2}
propertyPath: acceleration
value: 8
objectReference: {fileID: 0}
- target: {fileID: 114537395268845308, guid: f5beac725b81ce84e9335ad6d595f36f,
type: 2}
propertyPath: maxSpeed
value: 10
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: f5beac725b81ce84e9335ad6d595f36f, type: 2}
m_IsPrefabParent: 0
......@@ -693,7 +703,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
acceleration: 8
brakeFraction: 0.92
maxSpeed: 11
maxSpeed: 10
player: {fileID: 1530915660}
--- !u!50 &1530915662
Rigidbody2D:
......@@ -1005,7 +1015,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
engageDistance: 10
maxDistance: 20
elasticity: 1
curDistance: 0
playerOne: {fileID: 970431135}
......
......@@ -65,7 +65,7 @@ public class PlayerBehavior : MonoBehaviour {
// Update is called once per frame
void Update () {
/* Accelerate the player with a movement vector based on this frames input */
playerBody.AddForce(frameMovement.normalized * acceleration));
playerBody.AddForce(frameMovement.normalized * acceleration);
/* Cap player speed with a velocity check */
if (playerBody.velocity.magnitude > maxSpeed)
......
......@@ -61,8 +61,12 @@ public class PlayerTetherScript : MonoBehaviour {
/* if The players are far enough apart... */
if (curDistance > engageDistance)
{
/* Apply force of Distance, Scaled by elasticity, and divide among both players */
float tension = (elasticity * (curDistance - engageDistance)) / 2;
float distance = curDistance - engageDistance;
/* Apply force of Distance squared, Scaled by elasticity, and divide among both players
*
* I used distance squared to make the tether more responsive, though less realistic. - Clint
*/
float tension = (elasticity * (distance * distance)) / 2;
/* Vector difference gets magnitide = tension */
difference = Vector3.ClampMagnitude(difference, tension);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment