From 5755a614a5a12a5c47fd8a4ab48f30f69e59fa66 Mon Sep 17 00:00:00 2001 From: shieldgenerator7 Date: Tue, 22 Mar 2016 17:28:04 -0400 Subject: [PATCH] Camera follows Merky The camera no longer loses focus of Merky when falling --- Assets/Scenes/TutScene01b.unity | 16 ++++++++++------ Assets/Scripts/CameraController.cs | 7 ++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Assets/Scenes/TutScene01b.unity b/Assets/Scenes/TutScene01b.unity index def908913..3be5012fa 100644 --- a/Assets/Scenes/TutScene01b.unity +++ b/Assets/Scenes/TutScene01b.unity @@ -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 @@ -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 @@ -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 @@ -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} diff --git a/Assets/Scripts/CameraController.cs b/Assets/Scripts/CameraController.cs index 5d143ecae..ca8ca02d7 100644 --- a/Assets/Scripts/CameraController.cs +++ b/Assets/Scripts/CameraController.cs @@ -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; @@ -15,7 +16,7 @@ public class CameraController : MonoBehaviour { void Start () { offset = transform.position - player.transform.position; cam = GetComponent(); - + playerRB2D = player.GetComponent(); } void Update() @@ -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); } }