Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CamScript : MonoBehaviour
  6. {
  7.  
  8. public Transform target;
  9.  
  10. public float smoothSpeed = 0.125f;
  11. public Vector3 offset;
  12. private Camera mainCamera;
  13.  
  14. //private Mouse mousePosition;
  15.  
  16. void Start()
  17. {
  18. mainCamera = FindObjectOfType<Camera>();
  19. mainCamera = Camera.main;
  20. }
  21. void Update()
  22. {
  23. var mousePosition = new Vector3(Input.mousePosition.x/Screen.width, Input.mousePosition.y/Screen.height, 0f);
  24. //mousePosition.normalized = new Vector3(Input.mousePosition.x/Screen.width, Input.mousePosition.y/Screen.height, 0f);
  25.  
  26. Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition);
  27. Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
  28.  
  29. transform.position(target.position + Camera.main.right * (mousePosition.normalized.x - 0.5f) + GetComponent<Camera>().up * (mousePosition.normalized.y - 0.5f));
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement