x


MouseLook rotates back problem

I'm writting a script, cinsists of two components, the first one witches between player mouse control and my rotation script:

function Update() {
    if (Input.GetKeyDown ("r"))
    {
        if (GameObject.Find("fpscontroller").GetComponent("MouseLook").enabled == false)
        {
            GameObject.Find("fpscontroller").GetComponent("MouseLook").enabled = true;
            GameObject.Find("fpscontroller").GetComponent("Rotater").enabled = false;
        }
        else
        {
            GameObject.Find("fpscontroller").GetComponent("MouseLook").enabled = false;
            GameObject.Find("fpscontroller").GetComponent("Rotater").enabled = true;
        }
    }
}

The second rotates the player around slowly:

function Update () {
    transform.Rotate(Vector3.up, 20* Time.deltaTime);
}

My problem is, that even if all the scripts are working fine alone, thus i can "look around" and after pressing "r" mouse freezes, and the player slowly rotates around, BUT if i press the "r" button again, the camera moves back to the start position (it ignores the whole rotation procedure). How could i make this work?

Thank You,

Agoston Torok, HAS, Institute for Psychology

more ▼

asked Mar 01 '10 at 12:03 PM

Agoston Torok gravatar image

Agoston Torok
42 5 5 9

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

1 answer: sort voted first

I solved it grrr, simply using a mouse look script instead of the builtin one:

function Update () { var h = 15 * Input.GetAxis ("Mouse X"); transform.Rotate (0, h, 0); }

more ▼

answered Mar 01 '10 at 02:05 PM

Agoston Torok gravatar image

Agoston Torok
42 5 5 9

(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:

x2158
x982

asked: Mar 01 '10 at 12:03 PM

Seen: 1127 times

Last Updated: Mar 02 '10 at 10:51 AM