Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Want to stop camera from rotate around car

Discussion in 'Scripting' started by greatrock, Apr 29, 2021.

  1. greatrock

    greatrock

    Joined:
    Aug 19, 2012
    Posts:
    43
    Hi all, i am trying to stop the camera from rotating around the car, this rotation happens at the end of the race, when i click next or switch scene. The car don't move when u press the gas button, it just stay there and u see rubber burning. would like to deactivate the rotation camera after i click next or switch scene, any help will be appreciated. thanks in advance.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Whatever script you're using to rotate the camera, try just disabling it. Hard to say more, because we don't have any information about how your camera rotation functions.
     
  3. greatrock

    greatrock

    Joined:
    Aug 19, 2012
    Posts:
    43
    Ok, I have the code, sorry about the late reply

    upload_2021-5-4_3-9-22.png
     
  4. MartinMa_

    MartinMa_

    Joined:
    Jan 3, 2021
    Posts:
    455
    will be good to add some logic like rotate if something is true

    or you can pause game with
    Code (CSharp):
    1.  Time.timeScale = 0;
     
  5. greatrock

    greatrock

    Joined:
    Aug 19, 2012
    Posts:
    43

    Thanks, i think i have to do some logic.

    sorry for taking so long to reply
     
  6. ShiftyGames

    ShiftyGames

    Joined:
    Sep 10, 2018
    Posts:
    16
    Code (CSharp):
    1. Public class FinishRotate : MonoBehaviour
    2. {
    3.     public static bool startRotating = false;
    4.    
    5.     void Update()
    6.     {
    7.         if (startRotating)
    8.         {
    9.              transform.Rotate(0, 1, 0, Space.World;
    10.         }
    11.     }
    12. }
    Then you can enable and disable rotating from another script like this:

    Code (CSharp):
    1. FinishRotate.startRotating = true;
     
  7. greatrock

    greatrock

    Joined:
    Aug 19, 2012
    Posts:
    43

    Thanks,
    I want to add this to the next button so it can unpause, because i have the rotation camera hidden at the start of the race. So when i click next it will unpause the same time.
     
    Last edited: May 20, 2021