ok thanks
MMasegi
- Jan 29, 2024
- Joined Feb 14, 2023
- Edited
Hi,
I'm trien to make the camera zoom and rotate only around the center.
When I use this settings its working fine on desktop, but on mobile, as soon as I zoomed, it will not rotate around gameobject center anymore, it will rotate then around zoom center point
my current settings:
right/middle/two finger drag: none
One Finger Drag: Rotate Around
Two Finger Pinch: Zoom only
Scroll Wheel: Zoom in Centeri think im missing zoom in center on two Finger Pinch to fix this.
I now tried this one
public void focusCamera(bool instantSwitch, Vector3 direction, Vector3 upwards, float offsetX = 0, float offsetY = 0, float offsetZ = 0) { //instantSwitch = false; Vector3 targetPostion = new Vector3(fundament.GetComponent<Renderer>().bounds.center.x + offsetX, fundament.GetComponent<Renderer>().bounds.center.y + offsetY, fundament.GetComponent<Renderer>().bounds.center.z + offsetZ); float targetDistance = 20f; Quaternion targetRotation = Quaternion.LookRotation(direction, upwards); CameraPerspective.FocusCameraOnGameObject(modelBase, true); if (instantSwitch) { //if (CoroutineUnlockCam != null) //{ // StopCoroutine(CoroutineUnlockCam); //} CameraPerspective.MoveCameraToInstant(targetPostion, targetDistance, targetRotation); } else { //CameraPerspective.FocusCameraOnGameObject(modelBase, true); //CameraEvents.OnRequestObjectFollow?.Invoke(modelBase, true, false); CameraPerspective.MoveCameraTo(targetPostion, targetDistance, targetRotation); //camMode = cameraMode.Free; //if (CoroutineUnlockCam != null) //{ // StopCoroutine(CoroutineUnlockCam); //} //CoroutineUnlockCam = StartCoroutine(unlockCam()); } }
But now I get transform.position assign attempt for 'TouchCamera' is not valid. Input position is { NaN, NaN, NaN }.
yes but i only see pink squares cause auf urp. cant u just fix my function? otherwise just refund
but thats the part, what is working fine ...
- Edited
Hi, I have a object resizing itself.
When I focus the object with MoveCameraTo its working fine.
But when I try to do the same in 1 frame, it changes to a wrong distance.
Basicly what I use is this function:
public void focusCamera(bool instantSwitch, Vector3 direction, Vector3 upwards, float offsetX = 0, float offsetY = 0, float offsetZ = 0) { Vector3 targetPostion = new Vector3(fundament.GetComponent<Renderer>().bounds.center.x + offsetX, fundament.GetComponent<Renderer>().bounds.center.y + offsetY, fundament.GetComponent<Renderer>().bounds.center.z + offsetZ); float targetDistance = 20f; Quaternion targetRotation = Quaternion.LookRotation(direction, upwards); if (instantSwitch) { if (CoroutineUnlockCam != null) { StopCoroutine(CoroutineUnlockCam); } CameraPerspective.MoveCameraToInstant(targetPostion, targetDistance, targetRotation); } else { CameraEvents.OnRequestObjectFollow?.Invoke(modelBase, true, false); CameraPerspective.MoveCameraTo(targetPostion, targetDistance, targetRotation); //camMode = cameraMode.Free; if (CoroutineUnlockCam != null) { StopCoroutine(CoroutineUnlockCam); } CoroutineUnlockCam = StartCoroutine(unlockCam()); } } IEnumerator unlockCam() { yield return new WaitForSeconds(2.0f); CameraEvents.OnRequestObjectFollow?.Invoke(modelBase, false, false); }
What am I doing wrong please?