Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraFollow : MonoBehaviour
- {
- public GameObject player;
- public Vector3 offset;
- public float rotateSpeed = 5.0f;
- void Start()
- {
- player = GameObject.Find("Player");
- offset = transform.position - player.transform.position;
- }
- void LateUpdate()
- {
- if (Input.GetMouseButton(1))
- {
- Quaternion angle = Quaternion.AngleAxis(Input.GetAxisRaw("Mouse X") * rotateSpeed, Vector3.up);
- offset = angle * offset;
- }
- transform.position = player.transform.position + offset;
- transform.LookAt(player.transform);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement