Created
December 19, 2016 23:11
-
-
Save romainPechot/8b231fbca0b2d7ce52d474a5fd5a177b to your computer and use it in GitHub Desktop.
3rd Camera Scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class OrbitPivot : MonoBehaviour | |
{ | |
public float sensitivity = 10f; | |
private void LateUpdate() | |
{ | |
if(Input.GetMouseButton(1)) | |
{ | |
transform.Rotate(Vector3.left * Input.GetAxis("Mouse Y") * Time.deltaTime * sensitivity, Space.Self); | |
transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * Time.deltaTime * sensitivity, Space.World); | |
Cursor.lockState = CursorLockMode.Locked; | |
Cursor.visible = false; | |
} | |
else | |
{ | |
Cursor.lockState = CursorLockMode.None; | |
Cursor.visible = true; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class TransformFollower : MonoBehaviour | |
{ | |
[SerializeField] | |
private Transform target; | |
[SerializeField] | |
private Vector3 offsetPosition; | |
[SerializeField] | |
private Space offsetPositionSpace = Space.Self; | |
private void LateUpdate() | |
{ | |
if(offsetPositionSpace == Space.Self) | |
{ | |
transform.position = target.TransformPoint(offsetPosition); | |
} | |
else | |
{ | |
transform.position = target.position + offsetPosition; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment