- Home /
Cockpit Camera Lookat
This is probably quite easy, but I've been banging my head against the wall for a while now, using the in game assets scripts, (mouse lookat and stuff)
I just can't seem to find a script that will do the following:
I want a camera.position to follow my carcamera.position, inside the cockpit, but when the user presses MOUSE1, the camera will pan around allowing the user to look around, but then when the user releases mouse1, the camera lerps back to it's "default position" (straight ahead)
I figure it's something to do with LookAt, but beyond that I get a bit stuck... As I'm pretty poor at 3d maths...
If anyone could point me at a script that does something similar, that'd be great.
Have you had a look at the default $$anonymous$$ouseLook script?
Yes, I've had a look at the $$anonymous$$ouseLook Script, but that seems to rotate round an axis - which isn't quite what I'm after...
I'm using this code:
function LateUpdate () { // Horizontal
var rotH = transform.localEulerAngles.y + Input.GetAxis("$$anonymous$$ouse X") * sensitivityH;
rotH = ClampAngle(rotH, $$anonymous$$H, maxH);
transform.localEulerAngles.y = rotH;
var rotV = transform.localEulerAngles.x - Input.GetAxis("$$anonymous$$ouse Y") * sensitivityV;
rotV = ClampAngle(rotV, $$anonymous$$V, maxV);
transform.localEulerAngles.x = rotV;
Your answer
![](https://koobas.hobune.stream/wayback/20220613104536im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to setup camera look at mouse on right click 0 Answers
simple camera script 0 Answers
Adjust camera rotation while looking at a target 1 Answer
Camera rotate with mouse in TPC 0 Answers
I'm having problems with running my game on Ubuntu/Linux. 2 Answers