x


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.

more ▼

asked Feb 15 '11 at 05:32 PM

Chris 17 gravatar image

Chris 17
22 2 2 3

Have you had a look at the default MouseLook script?

Feb 15 '11 at 06:00 PM e.bonneville

Yes, I've had a look at the MouseLook 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("Mouse X") * sensitivityH;
rotH = ClampAngle(rotH, minH, maxH);
transform.localEulerAngles.y = rotH;


var rotV = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * sensitivityV;
rotV = ClampAngle(rotV, minV, maxV);

transform.localEulerAngles.x = rotV;
Feb 17 '11 at 12:53 PM Chris 17

argh, that didn't help...

:(

Feb 17 '11 at 12:54 PM Chris 17
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3001
x984
x329

asked: Feb 15 '11 at 05:32 PM

Seen: 938 times

Last Updated: Feb 15 '11 at 05:32 PM