x


How can i switch the MouseOrbit script to work for me?

I have been making a 3rd person fighter game and but i haven't made a good camera script yet. I made a script that can rotate my character (which is just a cylinder with a face) and make him walk and run, but i need a camera script. I would like to use the MouseOrbit script because it is what i am looking for, but i need some help. One thing is I need help with is when i rotate the camera to look, i would like the character to rotate as well to face the direction the camera is facing. How would i sript that? I tried to script it myself but obviously i don't know a lot of scripting.

more ▼

asked Dec 31 '10 at 02:24 AM

Tyler Alvis gravatar image

Tyler Alvis
215 43 50 57

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

i wanted exactly the same thing. do this:

var cameraMO : Camera; //with the mouseOrbit script

function Update()
{
 transform.localEulerAngles = cameraMO.transform.localEulerAngles;
}

that should so when your camera rotates your player also rotates

MAKE SURE you add this script to your player.

also, might want

if(transform.localEulerAngles.x != 0)
{
 transform.localEulerAngles.x = 0;
}

to keep the player from rotating to look straight down (and be floating (perfect for space though))

more ▼

answered Dec 31 '10 at 02:39 AM

Jesus_Freak gravatar image

Jesus_Freak
1.2k 38 44 59

It says Assets/my scripts/walker.js(57,47): BCE0019:'localEulerAngles' is not a member of 'UnityEngine.Camera'. how do i fix that?

Jan 02 '11 at 06:43 AM Tyler Alvis

sorry, just add "transform." after "cameraMO." so it would be cameraMO.transform.localEulerAngles.

Jan 02 '11 at 09:31 PM Jesus_Freak
(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x21

asked: Dec 31 '10 at 02:24 AM

Seen: 415 times

Last Updated: Dec 31 '10 at 02:24 AM