- Home /
how can I fix .SetActive ruining rigidBody physics?
Hi, I am trying to make a racing game, and the physics were pretty much the hardest things I faced, yet there's a big problem. When I .SetActive(true) a car object (which has a rigid body attached to it and moves with), it just slips when I add force to it even though I increased its materials' friction and so with the terrain's. Thanks in advance!
and it doesn't do that when active from the beginning?
no, I set it un-active in scene mode, and then in play mode a script sets them active, but otherwise if they're active from the start the game runs perfectly.
Good day.
This is strange... And if you Instantiate them from the script? Are you only doing that? Un-active from the scene and in run do SetAcvtive(true) ? Only this change make the physics to change?
Yes, that was what ruined the physics. Also, the car was un-activated from the beginning, and I set it active from the script. When I instantiate it, everything goes fine, but as I said, I had to fill its parameters, yet you cannot fill a prefab's parameters.
Answer by ics_de · Jul 04, 2018 at 10:57 PM
Are you sure the problem is related to the .SetActive()? I mean, if you directly start with the car in a scene it doesen't slip? If the problem is the .SetActive(), the easiest alternative is to instantiate the car.
I hope it helps, Uri.
I don't know whether the problem is related to .SetActive or not, but activating an object using it causes the car to slip, and suddenly the game goes bonkers. I also tried to instantiate the car, yet I had to fill the parameters with objects that had no tags, and you can't fill the parameters of a prefab anyways.
Yet, I found another solution to the problem, which is to destroy all other cars, and keep the chosen one, where they'd all be activated, from the beginning.
Your answer
![](https://koobas.hobune.stream/wayback/20220612165836im_/https://answers.unity.com/themes/thub/images/avi.jpg)