Physics acting very differently on Mac Mini vs. iPhone

I’ve read that physics will behave differently between the iPhone and Mac and I’m seeing it in huge way when I test in Unity versus deploying to my device.

My question is this, do I need to adjust the physics setting based on the iPhone model? For example, an item that bounces wildly all over the place on my Mac Mini moves at a normal rate on the iPhone. But, I am testing on an iPhone Touch 2nd generation and not on every device possible.

I have an iPhone 1st gen, and an iPhone Touch 2nd gen, but do not own all of the various models out now. Any suggestions on what to do?

Hi,

I also submitted a bug report shortly ago according physics and accelerometer. Though I’m not sure if thats related to your physics question.

Last email I wrote in response to support team:

If you place iPhone on the table it doesn’t really mean that accelerometer
will point straigth down. E.g., are you sure your table is 100% straight
on the ground?

A pretty straight table, yes! I put it on a surface that I measured before with an air-lever. But even on a non-straight surface it would be easy to counter-check by simply rotating the device by e.g. 180° degrees. The sphere should roll then into the opposite direction, but it doesn’t. It’s still “this only” direction.

Besides every device will have its own unique error, that is why some
games have accelerometer calibration option. Those may be limitations of
hardware.

It’s not caused by the device! As I claimed before it also happens with disconnected device. Just disconnect your device and hit the play button in Unity. You will see, the ball will still roll into the same direction.

Also remember that PhysiX engine implements a gravity which actually has a
constant force. Though you may tune it through the options page in the
Editor.

I know! I checked the default settings of gravity in the physics manager. Then, even played around with small values of X and Z to compensate this mysterious force. The result of this is less acceleration by this “force” but at certain values it starts to swap direction. It doesn’t go away. Anyway this would have been a “bad” workaround. If this force is gravity (y = -9,81) the sphere should roll down the hill, shouldn’t it? But it’s rolling upwards, very weired!? Means: I adjusted the ground (cuboid) by little(!) rotation values pointing up in the direction of this mysterious force. As described before the sphere goes up the hill. With larger rotation values gravity will win again over this force. This happens with connected and disconnected device!

Beside noise created by the device unity produces it’s own permanent noise!
Check this: Disconnect or switch off your device! Then, open the attached example project or create your own based on the roll-a-ball example. Simply replace/deactivate theBoard and Colliders with a cuboid plane (+ collider). Add Debug.Log("dir.x = "+ dir.x + "and dir.y = " + dir.z); in the controller.js. It will log “dir.x = 0.03622437 and dir.y = 0.03622437”.

The last sentence should be corrected: instead of “dir.y” in the string it must be “dir.z”, obviously :slight_smile:

As nobody confirmed this until now, it could be just me or my iDevice (iPod)… . As it’s easy to reproduce this, maybe you could try it and tell me what happend. Simply import the attached package. Also I had the impression that physics materials didn’t really work. But I didn’t dig deep into this.

204999–7552–$roll_a_ball_weired_force_141.zip (586 KB)

This may be what I am seeing in the thread I logged last week:

http://forum.unity3d.com/viewtopic.php?t=29179

This is also on a Mac Mini.

Steddy

strange, I’m pretty sure I attached the project-package with my previous post… ok, so once again

204999–7552–$roll_a_ball_weired_force_141.zip (586 KB)

Physics should behave more or less the same, unless you have really really miserable framerate. Make sure you do not do anything physics related in the Update or OnGUI functions.

Hmm, right now the behavior is vastly different. Can you elaborate on no physics related calls in Update?

All physics updates should be done in FixedUpdate, not Update, as the documentation states. Correct and consistent behavior is predicated on having the physics updates occur at fixed intervals, based on the time step you specify in your project settings. The frame rate on your mini is probably something like 100 FPS (Unity constrains it that point I believe) and only 30 or so on your device, so if you are updating physics in your Updates, you can end up with dramatically inconsistent behavior.

I am running everything in FixedUpdate() per the manual but wasn’t sure what was meant by Physics related calls in Update(). In FixedUpdate() I’m adding forces for when you affect the objects. Nothing is happening in Update(), although the function is there.

Can you post some code from your FixedUpdate so we can take a look? It’s hard to understand what might be going otherwise.