- Home /
Gravity is different on ios for Unity 2019
The gravity on an ios build seems to be less than 1/2 what it is in the editor. I've checked and changed the targetFrameRate and it doesn't seem to make a difference. I put a fps counter and it seems to be the same in the editor and ios but the gravity is still slow. I'm using 2019 and this did not happen with previous versions. Seems to only be affecting gravity not forces. All other physics and time settings are default. What else could cause physics speed changes?
Answer by JonPQ · Jul 02, 2019 at 10:32 PM
gravity / physics has changed at least once before, when Unity changed the physics engine. (totally borked my mobile game) Check to see if unity has changed the physics engine in 2019 compared to the previous version you were using.
As long as I can remember Unity had always used Nvidia's PhysX engine. Yes they did update to newer implementations (since Unity had gone a long way already) but it's always the same physics engine. Unity had additionally implemented 2d physics aside of the usualy 3d physics and is using Box2D since the first day of Physics2D. Though even between different implementations there shouldn't really be a major behaviour difference. Also the default gravity acceleration is set to -9.81 units per second squared in the player settings and that also never got changed.
It's more likely that there is some "force adding" code in his project that is not inside the FixedUpdate callback. The point of FixedUpdate is to provide a fix call count per second (by default 50 calls). The actual visual framerate is usually irrelevant if everything is done right.
@dansav if you want other people to reproduce your case you should tell us your exact Unity version. Are you sure you don't use an alpha or beta version? So theres no "a" or "b" in the version code but ins$$anonymous$$d an "f"(final) or "p"(patch)? I don't have a mac nor an IOS device so I can't verify or reproduce this issue. Even it's possible that there might be a bug in a recent release, it's very unlikely. Do you actually see this change only on the iOS device but not in the editor? Or has the overall functionality changed?
Just did a quick check: the latest Physics engine update was in Unity version 2018.3 where they actually updated to the latest PhysX version. There are some $$anonymous$$or default value changes in the versions between. However nothing that should break gravity. The acceleration is defined in unity per second squared. So that's a fix amount. As long as you don't mess with Physics.gravity in code there should be no reason for it to change. This of course assumes that time still increases at one second per second ^^.
Unity 2019.1.1f1 I tried a basic scene with gravity and it appears to be the same in both ios and editor. $$anonymous$$y scene does have some extra forces, but it is in the fixedUpdate loop so it shouldn't change anything but apparently it does. Either that or it's something to do with drag. But in the past everything was exactly the same in editor and ios.
So maybe something is going on with rb.AddForce(acc,Force$$anonymous$$ode.Acceleration) or drag related to ios. I'll have to do some more experiments to find out.
as Bunny83 says, fixed update is called not once pre frame, but once per fixed update time step.. so if your time step got reset or changed when you updated, your acceleration from your timestep will change, unless you as factoring in the timestep in your force adding. (note, the time should be the timeStep, not Time.deltaTime)
@Bunny83 , Unity didn't change the engine, but a few years ago they did previously Update it, making some fundamental changes, especially to the wheel collider / car physics. Probably does not apply in this situation, but I did see they were going to add a second physics engine option to unity sometime in 2019 or soon https://blogs.unity3d.com/2019/03/19/announcing-unity-and-havok-physics-for-dots/