The question is answered, right answer was accepted
How to switch between Time.unscaledDeltaTime and Time.deltatime after Time.timeScale?
This is my first time working with unity and coding an actual game so a lot of things are new to me. I am trying to make a "time control" ability that makes use of time scale so I used Time.unscaledDeltaTime to make the character move when time is slowed. No issues there. However when I pause the game I want to make the character and camera to stop moving. Every attempt I had at doing it failed. I tried making a code that checks if the game is paused and then multiply the speed by 0 or switch between Time.unscaledDeltaTime and Time.DeltaTime whenever the game is paused however nothing worked.
Codes:
Game Pausing: https://pastebin.com/vBxtL3Ff
Player Movement: https://pastebin.com/3rT1dGnW
Mouse Looking Script (For the camera itself in a third person view): https://pastebin.com/cTTSCE83
Camera Rotation Script (For the object the camera is on in a third person view): https://pastebin.com/4pV74Dp4
Time Control Script:https://pastebin.com/LPjwhNM8
A lot of this code is copied from open source however not everything I am trying to do can be found online. My problem is very critical for me because I need to be able to pause the player and camera when the game is paused regardless of the fact I am using Time.unscaledDeltaTime in their scripts. Is there any simple solution for that?
So there's this small fix that comes to my $$anonymous$$d, create a variable delTime in each of the script that have this change...and when you need to change the time from normal Time.deltaTime to Time.unscaledDeltaTIme....just change the value of the delTIme through a simple if loop to use unscaledDeltaTime in the update method.......
and then use that delTime instead of the regular Time.deltaTime..in the scripts....you can create a separate script and use a singleton to reference it in all these scripts
It's working. Thank you very much! Setting a singleton instance inside the game pausing script and changing delTime only within that script let me change the unscaledDeltaTime to deltaTime before the timeScale even changes to 0.
Follow this Question
Related Questions
why does timescale not work? 2 Answers
How to pause camera movement? 0 Answers
Moving moving Object with left/right arrow keys in a circular direction 3 Answers
Need help player movement 0 Answers
Camera drag move 0 Answers