|
|
@ -17,6 +17,8 @@ public class thirdPersonController : MonoBehaviour { |
|
|
|
public float cameraSpeedX = 250.0f; |
|
|
|
public float cameraSpeedY = 120.0f; |
|
|
|
public float cameraDistance = 10.0f; |
|
|
|
public float maxY = 80; |
|
|
|
public float minY = -20; |
|
|
|
public bool active = true; |
|
|
|
|
|
|
|
public float movementSpeed; |
|
|
@ -118,6 +120,9 @@ public class thirdPersonController : MonoBehaviour { |
|
|
|
cameraX += Input.GetAxis (CAMERA_INPUT_X) * cameraSpeedX * 0.02f; |
|
|
|
cameraY += Input.GetAxis (CAMERA_INPUT_Y) * cameraSpeedY * 0.02f; |
|
|
|
} |
|
|
|
|
|
|
|
cameraY = ClampAngle (cameraY, minY, maxY); |
|
|
|
|
|
|
|
Quaternion cameraRotation = Quaternion.Euler (cameraY, cameraX, 0.0f); |
|
|
|
Vector3 cameraPosition = cameraRotation * new Vector3(0.0f, 0.0f, -cameraDistance) + cameraCentre.transform.position; |
|
|
|
|
|
|
@ -194,10 +199,13 @@ public class thirdPersonController : MonoBehaviour { |
|
|
|
curCollider = col.collider; |
|
|
|
} |
|
|
|
|
|
|
|
//void onCollisionExit(Collision col){
|
|
|
|
// if (curCollider == col.collider)
|
|
|
|
// curCollider = null;
|
|
|
|
//}
|
|
|
|
private static float ClampAngle (float angle, float min, float max) { |
|
|
|
if (angle < -360) |
|
|
|
angle += 360; |
|
|
|
if (angle > 360) |
|
|
|
angle -= 360; |
|
|
|
return Mathf.Clamp (angle, min, max); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |