this is a little bit strange. it makes sense in a way. BUT.
i have a pause screen, happy with it, it passes and unpauses. but when i unpause after some time has passed ALL of the enemies are super fast.
im gathering that this has to do with Time.timeScale. but i had put that to 0. when pausing, but really I’m a little bit unsure
here is my current code that i have done. it works all fine just this speeding un after unpausing
While your code is functionally tight (in the sense due to your conditional checks, you’re technically not assigning timeScale every frame), I would refactor it accordingly for readability:
private bool paused = false;
//Unless you want to have some kind of fancy time bending effects, I'd leave unpaused speed as a constant, 1f == realtime
private const float UnpausedSpeed = 1f;
void Update () {
if(Input.GetKeyDown("esc") ){
paused = !paused;
Time.timeScale = (paused) ? 0f : UnpausedSpeed;
pauseScreen.enabled = (paused);
}
}
That being said, it DOES look to me like the speeds should be accurate. Try either this code, or logging what TS is computed as. I’m imagining the problem is originating from somewhere other than this code.
hmmm. it did work. so thanks for that. but still getting this speed up when unpausing.
looking at my code for anything that contains speed, there is nothing apart from the enemy which is not related to Time.timeScale, but rather a box2d rigidbody2d.AddForce for its movement
other than that, i can’t see anything. ill dig deeper
but thanks again. yours does look much cleaner [special officer doofy]
weridly it works like that. i worked from things i found or could find. but this was a hack of something i found.
did try another way. much simpler that i have made, but still the process is the same. it speeds up all the other items. also if any box2d items are flying away from you if they miss, once you press pause, leave for a few seconds and then unpause, they have changed direction right towards you. obviously they are aimed to go to you, but the change in direction is interesting
no im just stumped by this. i cant figure it out at all.
no matter what i try with pausing and unpausing, the enemies continue to gain a momentum whilst paused, so when i finally unease, they are super fast.
i just don’t know what to do to be honest. ive actually tried 6 different ways, actually more 9. but i cant figure it out
if anyone can shed some light id be happy. but still thanks to the people who have helped up to now