Might be the same category of stuttering that’s going around but maybe not.
So I tried making a simple little pinball game. Two flippers and two bumpers.
Maybe 50 lines of code, default grey, 1 light, simple geo. Basically nothing what so ever that should cause any problems.
Here comes the catch:
My mac: Everything runs perfect at 120 fps, no stuttering no nothing.
iPhone: 30 or 60fps setting: it will stutter tremendously when hitting the first flipper and the first bumper. Both have ‘on trigger enter’ commands on them, then just add a vector to velocity to bounce it off.
Android: 60fps and exactly the same phenomenon as on iOs
Thing is, it stutters only once. So if you made it through the initial stuttering everything runs smooth.
But well, it should be commercial at some point and such stuttering is not really granting 5 star reviews 
Anyone experiencing that, file a bug report? Any idea welcome.
I have been working with procedurally generated rotating physics “levels” and balls for quite a long time now on iOS and there’s absolutely no issues you can’t fix.
Some of the obvious things to look out for:
-
you shouldn’t use continous or continousDynamic - instead cap your maximum speeds with ClampMagnitude if they are recoiling and bouncing through scenery as this will be considerably better performance than above flags.
-
ensure physics rigidbodies have interpolate turned on for smoothness.
-
make absolutely sure you DO perform ALL calculations in FIXED UPDATE, not OnCollisionEnter and so on. You should instead set a flag on the object so your fixedupdate code knows it’s collided… Also ensure youre not using oncollisionstay for this.
Again: all physics changes must take place in fixedupdate, and must not use time.deltaTime in fixed update.
- Ensure that any physics objects which are meant to move or rotate do NOT have static set and only use either compound primitive colliders or convex colliders, not mesh colliders, as it will stall the system precalculating what it thinks isn’t supposed to be moving (mesh colliders or static marked colliders will cause a heavy performance hit if you move or rotate them).
1 Like
Thanks a lot for all those tips Hippo!
I will keep them in mind since I pretty much did exactly the opposite in each and every step you explained, hehe. Wasn’t aware of most of that. Still confused how I should do an on collide if I shouldn’t use the on collide.
If I get you right I should set a value/parameter in the onCollision event that gets processed in the fixed update?
Without having the time to make all the changes I think one reason was me being too impatient. Since it’s a prototype you’ll end up in game pretty much the second you are after the loading screen. I assume it’s still loading something. I placed the ball somewhere else so it has more time to come to speed. It will stutter as before while moving but not when touching all the objects. Looks like some kind of computation pause after loading the level.
In the end it will be sort of avoided since the ball is in the start ramp anyway, etc. Or it will be gone once I put all your tips in the script.
Thanks again hippocoder.