- Home /
Scaling down my model or scaling up the gravity
Hi, thanks for taking time to help me. I have a simulation of a project, a self driving car that I train on Unity and I would like to scale it to the actual size of the real car we re gonna make (30 by 20 centimeters). The problem is that when I scale it to this size the physics engine acts really weird and the car is shaking. So I thought I just had to scale my car by a factor of 3 or 2 and scale up the gravity by the same amount in Edit/Project settings/physics.
Answer by calpolican · Jan 16, 2018 at 12:44 AM
Well, the values are made for the scale the car has. Scaling the car down will surley ruin the asset. Are there many other things in your scene? if I where you, I'd just scale up the model of the world instead. Is either that or you try to change all the values for speed and damping, etc that may be in the asset scripts, that may get tricky. I wouldn't touch the gravity at all, that will make a mess.
Yes I could scale everything up but I have a real physical model that I want to simulate in Unity so I would like to have the real weight, the real size so that the real model and the unity model behave similarly
Well, if you want to do some sort of physics simulation that will give you an idea of how the actual car will behave in real life, keep in $$anonymous$$d that most probably the car asset is faking the physics a lot. For example, most games don't have a collider and rigidbody for every wheel, they don't have back traction and don't calculate the friction of the wheels against the floor, the wheels just move by an animation whos speed is linked to the car speed. I'm just saying as I don't know how accurate you need your simulation, but keep in $$anonymous$$d that usually game programmers just adjust the parameters to make them feel like something they consider realistic. In that spirit, if you want to use the asset and don't $$anonymous$$d some inaccuracy, you should change the parameters. Obviously you can't make a 20cm car accelerate as fast as a real one, in that case it'll move very weird of course. You'll have to change the speed, the weight, and the rest of the values accordingly to try to match --as best as you can those of your game--. Just saying that in my experience those changes are somewhat tricky. You should try to figure out the formula they use (the proportions), maybe it's comented in the scripts, or maybe the asset is related to some tutorial, in that case, you should probably watch it and see... perhaps you're lucky and there's some built in scaler multiplier.
ok thank you very much for helping it s a bit more clear for me now. I m gonna check if there is a scalar multiplier but since my car goes really slow I think I m not gonna $$anonymous$$d avout the gravity ;)
Answer by Dray · Jan 11, 2018 at 10:22 AM
In general, you should always try to keep objects at their real world scale to get the most accurate physical behaviour. Maybe you can counteract the shaking by adjusting the rigidbodys mass and drag values?
I'd also like to ask how exactly you implemented the movement. Can you post a snippet or something? Might make it easier to help you :)
Thank you for helping, I simply used the standard asset's vehicle folder where you can find a premade car named car in StandardAsset/Vehicles/car/Prefabs. You can make a scene and put it in very quickly. Try setting the scale to 0.30 by 0.20 and you ll see that when you launch the game nothing behaves right :/.
But why scale it down? It's meant to be used in its original size I'm pretty sure, did you try scaling everything else up?
$$anonymous$$eep in $$anonymous$$d that physics behave totally different when you look at the same object in different scales
Do you mean that you use the vehicle game object's Transform and set it to (0.3, ?, 0.2)? In that case, this could be the problem, there are issues with non-uniform scaling in Unity.
Or if you are talking about the scale of the Collider, then the forces that affect the vehicle might be too strong (I'm not familiar with this Standard Asset). Try to check what forces control the vehicle.
One more thing you could try is to make the physics simulation more precise by setting the Fixed Timestep in Edit -> Project Settings -> Time to a lower value, like 0.01 (but be aware that 60 FPS has an update cycle of 0.1666 seconds!).
In any case, I strongly advise against changing gravity scale, Unity and PhysX are designed for "real" world-like physics simulation, and all kinds of bugs pop up when certain values are changed.
Answer by meat5000 · Jan 17, 2018 at 02:02 PM
Unity lacks an actual per-unit scale and is pretty open to interpretation of what measurement 1 unit should correspond to. The rule of thumb is that your scale is correct when your free-fall gravity responds correctly.
Very large or very small scales should be avoided as they cause problems and strange behaviour.