- Home /
Question by
Blackice000 · Apr 20, 2014 at 11:27 PM ·
cameramovementcamera-movement
Camera Movement
Sample code parts:
void Drag()
{
xAxis += Input.GetAxis("Mouse X") * xSpeed;
yAxis -= Input.GetAxis("Mouse Y") * ySpeed;
}
void UpdatePosition()
{
transform.position = CalculatePosition(yAxis * ySpeed, xAxis * xSpeed, zoomDefault);
transform.LookAt(target);
}
Vector3 CalculatePosition(float rotationX, float rotationY, float distance)
{
Vector3 direction = new Vector3(0, 0, -distance);
Quaternion rotation = Quaternion.Euler(rotationX, rotationY, 0);
return target + rotation * direction;
}
The problem is, I can drag just fine with that, but if I want to change the camera position without changing the target position, like, and still work on the same object. How do I do that?
Comment