|
@ -9,6 +9,8 @@ public class CameraFollower : MonoBehaviour |
|
|
[SerializeField] private float m_FollowStrength = 3f; |
|
|
[SerializeField] private float m_FollowStrength = 3f; |
|
|
[SerializeField] private bool m_FollowX = true; |
|
|
[SerializeField] private bool m_FollowX = true; |
|
|
[SerializeField] private bool m_FollowY = false; |
|
|
[SerializeField] private bool m_FollowY = false; |
|
|
|
|
|
[SerializeField] private float m_OffsetX = 0f; |
|
|
|
|
|
[SerializeField] private float m_OffsetY = 2.0f; |
|
|
|
|
|
|
|
|
private Camera m_Camera; |
|
|
private Camera m_Camera; |
|
|
|
|
|
|
|
@ -22,8 +24,8 @@ public class CameraFollower : MonoBehaviour |
|
|
if(Mathf.Abs(Player.transform.position.x - m_Camera.transform.position.x) > m_FollowStrength) |
|
|
if(Mathf.Abs(Player.transform.position.x - m_Camera.transform.position.x) > m_FollowStrength) |
|
|
{ |
|
|
{ |
|
|
m_Camera.transform.Translate( |
|
|
m_Camera.transform.Translate( |
|
|
m_FollowX ? (m_FollowStrength + Player.transform.position.x - m_Camera.transform.position.x) * Time.deltaTime : 0, |
|
|
|
|
|
m_FollowY ? (m_FollowStrength + Player.transform.position.y - m_Camera.transform.position.y) * Time.deltaTime : 0, |
|
|
|
|
|
|
|
|
(m_FollowX ? (m_FollowStrength + Player.transform.position.x - m_Camera.transform.position.x - m_OffsetX) * Time.deltaTime : 0), |
|
|
|
|
|
(m_FollowY ? (m_FollowStrength + Player.transform.position.y - m_Camera.transform.position.y - m_OffsetY) * Time.deltaTime : 0), |
|
|
0); |
|
|
0); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|