So I’m trying to make my camera stop moving whenever I pause my game. Now I got the camera to work while the game is un paused, but I don’t understand how to stop it from moving while the timescale = 0.
Extra context/short description: I’m doing an fps controller but when I pause the camera keeps moving as my mouse does.
Here is my code:
public Transform player;
public static bool GameIsPaused;
void Update() {
if (GameIsPaused != true)
StartLook();
if (GameIsPaused = true)
StopLook();
}
void StartLook()
{
transform.position = player.transform.position;
}
void StopLook()
{
///this is where I'm having a hard time at use the code from StartLook() to help you
}
The only obvious issue I can see with this code is that your check for whether the game IS paused isn’t using the double equals “equality operator”, the single equals is the “assignment operator”.
When you do GameIsPaused = true
we will always return true regardless of what value GameIsPaused starts as. This is because the first thing this line does will be to ASSIGN GameIsPaused to equal True. Since it’s the condition for an if-statement it will then look at the result of this operation which is now also True.
To solve this, use the equality operator GameIsPaused == true
to check whether the GameIsPaused is equal to True. Since this will return a True or False value, this is equivalent to just writing if (GameIsPaused)
Unless it’s acted upon by other forces, to NOT move something you simply need to neglect to move it. So I would have thought an empty StopLook function is fine, as long as we don’t enter StartLook then there is no reason - from this code - that it should move.
From your description, I’ve got a feeling there is more code affecting the camera behaviour. If making this change doesn’t help then reply with any other code that is handling the ‘look’ rotation of your camera