Quantcast
Channel: Questions in topic: "around"
Viewing all articles
Browse latest Browse all 101

problem with rotate camera around player

$
0
0
i want to make camera rotate around player, but i can't edit the rotation or location, this my script. get touch : public Vector2 touchDist, pointerOld; protected int pointerId; public bool pressed; private void Update() { if (pressed) { if (pointerId >= 0 && pointerId < Input.touches.Length) { touchDist = Input.touches[pointerId].position - pointerOld; pointerOld = Input.touches[pointerId].position; } else { touchDist = new Vector2(Input.mousePosition.x, Input.mousePosition.y) - pointerOld; pointerOld = Input.mousePosition; } } else { touchDist = new Vector2(); } } public void OnPointerDown(PointerEventData eventData) { pressed = true; pointerId = eventData.pointerId; pointerOld = eventData.position; } public void OnPointerUp(PointerEventData eventData) { pressed = false; } and this my script to rotate camera around player : public Camera mainCamera1; public FixedTouchField touchField; public float cameraDistancePlayer = 11, cameraPosYMax = 11, cameraPosYMin = 1, cameraAngleY, cameraPosY, cameraPosHSpeed = 0.1f, cameraPosYSpeed = 0.03f; private void Start() { cameraAngleY = -180; cameraPosY = 6.279997f; } private void Update() { cameraAngleY += touchField.touchDist.x * cameraPosHSpeed; cameraPosY = Mathf.Clamp(cameraPosY - touchField.touchDist.y * cameraPosYSpeed, cameraPosYMin, cameraPosYMax); mainCamera1.transform.position = transform.position + Quaternion.AngleAxis(cameraAngleY, Vector3.up) * new Vector3(0, cameraPosY, cameraDistancePlayer); mainCamera1.transform.rotation = Quaternion.LookRotation(transform.position + Vector3.up * 2 - Camera.main.transform.position, Vector3.up); } with this script i can rotate camera around player, but i can't edit rotation and location, is there a way to rotate the camera around the player but I can edit the location and rotation of the camera ??, maybe it can use vector or something ??

Viewing all articles
Browse latest Browse all 101

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>