- Home /
Time.timescale fixed bad collision?
The problem is that initially the game had some collision problems especially at higher speeds however I was able to fix this because I tried adding a feature that would slow the game down and noticed that at a lower timescale the collision got worse so I increased the timescale to 10 and noticed that collision got a lot better(couldn't notice any errors at this point) and now I have it at 100 and there are no problems at all but I have no idea why this is so if anyone knows why or knows an alternative method to fix collision please tell me.I also use all the colliders as triggers in this game.
This is the game currently(Time.timescale = 100 when playing and 0 during pause or game over)
http://testgames58.tk/DDRgameV4/arrowgamev4.html
This is the previous version of the game(bad collision Time.timescale = 1 when playing and 0 during pause or game over)
Answer by NorthStar79 · Jun 27, 2018 at 02:01 PM
Hello, probably the main reason is; your scene scale isn't correct. you should consider 1 unit as 1 meter, if your objects are too small or too big, you can get errors like this. if you add screenshots from editor that shows how big your objects are we can tell much more. Also, probably you are moving your objects in Update() method instead of FixedUpdate(), if this is the case, move your movement code into FixedUpdate() and set your timescale to 1 again. if your objects are moving very fast you can decrease FixedUpdate Time step (Here a documantation)
I Hope this answer helps, good luck
The camera size is 7 units and I have used 1 unit as 1 meter in all my calculations and the only thing concerning physics that that I have in the game is
rb.velocity = new Vector2(rb.velocity.x, GameController.currentspeed);
which I have placed in fixed update already. I have also divided all the values being used by Time.timescale to make sure that the game will always move at the same speed regardless of Time.timescale. I want to post my code here but I can't since both the arrow behaviour script(I have one for each arrow but the only differences are about the input so if I can I will only post 1 of them) and the game controller script both exceed the character limit.
Your answer
Follow this Question
Related Questions
Activate trigger if items colected 1 Answer
OnCollisionEnter When isTrigger = false 3 Answers
Ignore collisions with self but still trigger with self 2 Answers
Resizing colliders and OnTriggerEnter 0 Answers
change material when ontrigger 1 Answer