Skip to content

Commit

Permalink
Camera follows Merky
Browse files Browse the repository at this point in the history
The camera no longer loses focus of Merky when falling
  • Loading branch information
shieldgenerator7 committed Mar 22, 2016
1 parent ca2a4cc commit 5755a61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 10 additions & 6 deletions Assets/Scenes/TutScene01b.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,11 @@ Prefab:
m_Modifications:
- target: {fileID: 446986, guid: 0b3255d4b4dc0a443a420e93fb27f62b, type: 2}
propertyPath: m_LocalPosition.x
value: 153.89
value: -0.005
objectReference: {fileID: 0}
- target: {fileID: 446986, guid: 0b3255d4b4dc0a443a420e93fb27f62b, type: 2}
propertyPath: m_LocalPosition.y
value: 32.6
value: -0.041
objectReference: {fileID: 0}
- target: {fileID: 446986, guid: 0b3255d4b4dc0a443a420e93fb27f62b, type: 2}
propertyPath: m_LocalPosition.z
Expand Down Expand Up @@ -13850,11 +13850,11 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 464668, guid: 5913bd1e88aefff4988c7dfee6595611, type: 2}
propertyPath: m_LocalPosition.x
value: 153.89
value: -0.005
objectReference: {fileID: 0}
- target: {fileID: 464668, guid: 5913bd1e88aefff4988c7dfee6595611, type: 2}
propertyPath: m_LocalPosition.y
value: 32.6
value: -0.041
objectReference: {fileID: 0}
- target: {fileID: 464668, guid: 5913bd1e88aefff4988c7dfee6595611, type: 2}
propertyPath: m_LocalPosition.z
Expand Down Expand Up @@ -18614,7 +18614,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 409136, guid: 61d77a5c634a9db4186a94e82dca7230, type: 2}
propertyPath: m_LocalPosition.y
value: -1.0900003
value: -3.03
objectReference: {fileID: 0}
- target: {fileID: 409136, guid: 61d77a5c634a9db4186a94e82dca7230, type: 2}
propertyPath: m_LocalPosition.z
Expand Down Expand Up @@ -18650,7 +18650,11 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 409136, guid: 61d77a5c634a9db4186a94e82dca7230, type: 2}
propertyPath: m_LocalScale.y
value: 0.26607183
value: 4.0789766
objectReference: {fileID: 0}
- target: {fileID: 21210666, guid: 61d77a5c634a9db4186a94e82dca7230, type: 2}
propertyPath: m_SortingOrder
value: -1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 61d77a5c634a9db4186a94e82dca7230, type: 2}
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class CameraController : MonoBehaviour {

private Vector3 offset;
private Camera cam;
private Rigidbody2D playerRB2D;

public float perspectiveZoomSpeed = 0.5f;
public float orthoZoomSpeed = 0.5f;
Expand All @@ -15,7 +16,7 @@ public class CameraController : MonoBehaviour {
void Start () {
offset = transform.position - player.transform.position;
cam = GetComponent<Camera>();

playerRB2D = player.GetComponent<Rigidbody2D>();
}

void Update()
Expand Down Expand Up @@ -100,9 +101,9 @@ void LateUpdate ()
transform.position = Vector3.MoveTowards(
transform.position,
player.transform.position + offset,
Vector3.Distance(
(Vector3.Distance(
transform.position,
player.transform.position) * 2
player.transform.position) * 2 + playerRB2D.velocity.magnitude)
* Time.deltaTime);
}
}

1 comment on commit 5755a61

@shieldgenerator7
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #11

Please sign in to comment.