Help scaling camera using VR Touch Controllers
Think I've fried my brain...
I'm trying to make a camera scale function for a VR game I'm working on, using touch controllers... So, pressing both trigger buttons down and pulling them away from each other will increase the world scale and pushing them together will shrink it.
I have it working somewhat... Using the code I've written the world scales quite well. But say I have scaled down using the controllers, then released the triggers, moved the controllers further apart, repressed the triggers, the scale jumps to the distance apart rather than adding onto the distance if that makes sense?
Anyway, here's the code, maybe someone could shed some light on what I need to do.
void Scale()
{
if (!scalePressed)
return;
float currentDist = Vector3.Distance(leftHandController.transform.position, rightHandController.transform.position) / cameraOffset.transform.localScale.x;
float clampedDistance = Mathf.Clamp(currentDist / 5f * 100f, minimumScale, maximumScale);
Vector3 scaleAmt = Vector3.one * clampedDistance;
Vector3 newScale = Vector3.Lerp(cameraOffset.transform.localScale, scaleAmt, clampedDistance);
cameraOffset.transform.localScale = newScale;
previousControllerDistance = clampedDistance;
}
Your answer
Follow this Question
Related Questions
Using the Oculus CV1 Remote 0 Answers
I'm adapting the portals from Brackeys to VR, how to stop Z axis from rotating in render texture? 0 Answers
I need a completely stationary camera for my VR game 1 Answer
How to scale an object so it fits perfectly inside a collider? 1 Answer
GoogleVR / C# - How to, with the "pointer click": click 1 move a cube and click 2 move back the cube 0 Answers