Skip to content

Commit

Permalink
Merge pull request #68 from Double-Fine-Game-Club/ball-movement
Browse files Browse the repository at this point in the history
Modifying min/max vel as well as applied force after collision
  • Loading branch information
Cheeseness authored Apr 24, 2017
2 parents 06ecfcc + 7760733 commit bf5c3e8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 70 deletions.
12 changes: 0 additions & 12 deletions Assets/entities/paddle/paddle-kednar/paddle_kednar1.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ GameObject:
- component: {fileID: 54419471106318242}
- component: {fileID: 114860991891888486}
- component: {fileID: 114513956183267584}
- component: {fileID: 114639248819474702}
- component: {fileID: 114854915380906086}
- component: {fileID: 114810037560900528}
- component: {fileID: 114754070099237892}
Expand Down Expand Up @@ -358,17 +357,6 @@ MonoBehaviour:
m_SnapThreshold: 5
m_InterpolateRotation: 1
m_InterpolateMovement: 1
--- !u!114 &114639248819474702
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1063936598707464}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3357c6c602746414dac7339d18529069, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114754070099237892
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down
12 changes: 0 additions & 12 deletions Assets/entities/paddle/paddle-kednar2/paddle_k2.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ GameObject:
- component: {fileID: 54560384471941002}
- component: {fileID: 114790716705188286}
- component: {fileID: 114087461496385640}
- component: {fileID: 114512921606720236}
- component: {fileID: 114299853246167256}
- component: {fileID: 114006545633556322}
- component: {fileID: 114557036188983720}
Expand Down Expand Up @@ -731,17 +730,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2275ac37e67904bc79427cc4f5875617, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114512921606720236
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1198390537249120}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3357c6c602746414dac7339d18529069, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114557036188983720
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down
12 changes: 0 additions & 12 deletions Assets/entities/shared/bumper_prefab.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ GameObject:
- component: {fileID: 33881615923883728}
- component: {fileID: 23246333471709452}
- component: {fileID: 64447266638017336}
- component: {fileID: 114351652613839056}
m_Layer: 0
m_Name: bumper_prefab
m_TagString: Bumper
Expand Down Expand Up @@ -96,14 +95,3 @@ MeshCollider:
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 4300002, guid: 136739c0c5b41a742a472b890d320d5c, type: 3}
--- !u!114 &114351652613839056
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1657032312230928}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3357c6c602746414dac7339d18529069, type: 3}
m_Name:
m_EditorClassIdentifier:
19 changes: 0 additions & 19 deletions Assets/scripts/entity/ApplyForceToBall.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Assets/scripts/entity/ApplyForceToBall.cs.meta

This file was deleted.

15 changes: 12 additions & 3 deletions Assets/scripts/entity/Ball.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ private void FixedUpdate()

if (rigidBody.velocity.magnitude < minimumVelocity)
{
rigidBody.velocity = rigidBody.velocity * 1.25f;
rigidBody.velocity *= minimumVelocity / rigidBody.velocity.magnitude;
}
if (rigidBody.velocity.magnitude > maximumVelocity)
{
rigidBody.velocity = rigidBody.velocity * 0.90f;
rigidBody.velocity *= maximumVelocity / rigidBody.velocity.magnitude;
}
}

Expand All @@ -63,7 +63,6 @@ public void ResetPosition()
transform.position = startingPosition;
}


void OnTriggerEnter(Collider Col)
{
// Only handle scoring server-side of local
Expand Down Expand Up @@ -103,4 +102,14 @@ void OnTriggerEnter(Collider Col)
ResetPosition();
}
}

void OnCollisionExit(Collision other)
{
if (other.gameObject.tag == "Paddle" ||
other.gameObject.tag == "Bumper")
{
Debug.Log ("Adding force to ball");
rigidBody.AddForce (rigidBody.velocity.normalized * 2.5f);
}
}
}

0 comments on commit bf5c3e8

Please sign in to comment.