Camera Rotation Script problem - Error or something else ?

Hello everyone !
I’ve a very strange problem in my project…
In the main menu, I have added a script to the camera , which rotates around a certain object…
it works perfectly fine when I press play button and test it, but when I’m playing the game and want to return to main menu (through pause menu), then at that time, the main menu successfully loads, but camera doesn’t rotate around that object :face_with_spiral_eyes::face_with_spiral_eyes:
I’ve checked that the script component is active (tick marked in inspector view), but then also it doesn’t rotate around the object…
here is that script:

#pragma strict


var targetCar : Transform;

function Start () {

}

function Update ()
{

	transform.LookAt(targetCar);
	transform.Rotate(0*Time.deltaTime,2*Time.deltaTime,0*Time.deltaTime);
	transform.Translate(2*Time.deltaTime,0*Time.deltaTime,0*Time.deltaTime);

}

can anyone suggest something ?
also, the rotation is kind of “jittery” / “shaky”, so, suggestions for smooth rotational movement around object are also welcome !!

Thanks in advance!

You mention you use a pause menu - do you stop time during this? Do you restart it when you return to your menu? Since your entire rotation is based on time, that would be my first place to look. As a side point, you also have some extra multiplies in your script: 0 * Something = 0

As for making it less shakey/jittery, here’s a small rotation script that I used for a model viewer a while back that might give you some ideas.

var target : Transform;
var distance = 10.0;

var YHeight = 10.0;
var Speed = 16.0;

private var x = 0.0;

function LateUpdate () {
    if (target) {
        x += Time.deltaTime * Speed;

        transform.rotation = Quaternion.Euler(YHeight, x, 0);
        transform.position = transform.rotation * Vector3(0.0, 0.0, -distance) + target.position;
    }
}

yes…I did perform Time.TimeScale =0; for pause menu.
but I also have written that if user chooses to return to main menu, then first Time.timeScale = 1 is performed and then user is routed to main menu…
BTW thanks for the suggestions for rotation script…

Edit : Sorry! sorry!:roll_eyes: I did Time.timeScale = 1 only for resume game option, and not for the “return to main menu” option…
silly me!:smile: