Unity is showing different physics behaviour while building for different devices - unity3d

I am working on roulette(Casino Style game) game project in Unity3D.
I am rotating a ball around a wheel and wheel is also rotating on its own axis in fixed update.
I am using transform.RotateAround function to rotate the ball around the wheel and i am also decreasing ball's speed in fixed update.I am assigning a random initial speed to ball within a range such that it always stops on different position each time .
For testing purpose i kept the initial ball speed to constant and check it in unity editor such that every time it rotates it always stops on the same number.
I build this project to android and PC .Though the ball stops on the same number each time in both android and PC build but the result is different in both of them.
For example- Every time ball rotates it stops on number 8 in android and number 20 on Pc each time.
Can somebody please suggest me some ways to obtain same result on different devices?
Why it is happening? Is unity physics behaviour is different in different processor?
and please explain me how to fix that .

Unity has a fixed time step, so that isn't the cause of the differences as one might expect. Physics simulations are incredibly complex things, so I'm not going to pretend that I know exactly why you're seeing differences. However, I would imagine it is to do with floating point precision differences between your computer and a much smaller phone processor.
One way to test this would be to run the simulation on another computer, and compare the results to the both of your current devices.

Related

Flutter Flame game - animation speed (update duration)

for those who are familiar with using Flame in Flutter for game development, I'm wondering if you can just advise me whether I'm on the right track, or not - because I'm not sure if what I'm seeing in my testing is what I expected. I started out with Flame because I thought it seemed like a relatively simple way to make the basic game that I'm aiming to make.
I'm making a basic game where there are four boundaries defined on each edge of the screen, and a ball will bounce around the four boundaries. The boundaries are defined as widgets (because I want to control the properties of each - sometimes they'll be "electrified", meaning the ball shouldn't collide with them). And the ball is a widget as well, of course. I've got some basic code done where I can drag a line from the ball to indicate the direction that I want to start bouncing, and then the ball will bounce around the boundaries (just using basic angle of incidence = angle of reflection to determine the direction of movement).
The code to do the movement is in the "update" method of the ball widget - however, what I'm finding is that the time between updates is somewhere around 200-300 milliseconds, so if I want to show the ball moving at any kind of pace, it has to jump a good number of pixels at each "update" tick - and thus the movement looks "jerky".
Am I doing this the right way? Is there a different (better) approach that will make the movement appear smoother? Or, I'm wondering whether the duration of the "update" ticks is a result of running the code via debug in an Android emulator? (I'm using Android Studio for the emulation, and Visual Studio Code to build the project). I know I don't have actual code here in the question, because essentially I don't have an issue with my code not running - I would just like to understand if that duration of "update" ticks is "normal", and if the resulting "jerky" animation is just to be expected - or do I need to look at a different approach? Thanks in advance!
You should preferably not be using widgets for moving game parts, you should be using Flame components. So you could have for example 4 SpriteComponents as the walls and then the ball as another SpriteComponent and then you can use the collision detection system to act upon when the ball touches one of the walls.
https://docs.flame-engine.org/main/collision_detection.html

Unity 3D: Adding rigidbody to sphere crashes frame rate

There is a strange issue happening in Unity 3D: I have an empty scene, then I add new sphere game object, press run, the ball stays stationary. I can see in the Game window that FPS are ok.
Then I add Rigidbody component to the same sphere and press play. The sphere starts to fall down as it should, but the frame rate drops dramatically, that is below 3 FPS.
I've updated the Nvida drivers, I also tried this in both 32 and 64 bit newest Unity versions.
It seems that there something wrong with the physics calculations.
Does anyone experienced similar issues?
Any tips on how could I debug this issue further?
Some times Vsync can act as the FPS dropper.
so check Edit>>Project Settings>>Quality>>V Sync Count
Set V Sync Count it to Don't Sync.
it should increase your FPS.
if it does not help than you might have some script that is acting as weird.
so try Profiler .Go to Windows>>Profiler .
and run your game see what is taking your highest CPU.

Unity 3D low fps

I'm using Unity3D 5.3 version. I'm working on a 2D "Endless running" game. It's working normally on PC. But when I compile it to my phone, all of my gameobjects are shaking when they are moving. Gameobjects are in a respawn loop. I'm increasing my Camera's transform position x. So when my camera is in action, all of the other objects look like they are shaking a lot and my game is working slowly on my phone as a result. I tried to play my game at Samsung, on discovery phones. It's working normally on some of them. But even on some Samsung devices it's still shaking. So i don't understand what the problem is. Can you help me with this?
One thing you can do is start optimising, if you have a game that is either finished or close to it. If you open the profiler, click "Deep Profile" and then run it in the editor on your PC, you'll get a very detailed breakdown of what is using the most resources within your game. Generally it's something like draw calls or the physics engine doing unnecessary work.
Another thing that might help is to use Time.deltaTime, if you aren't already. If the script that increases the transform doesn't multiply the increase by Time.deltaTime, then you're moving your camera by an amount per frame rather than per second, which means that if you have any framerate drops for any reason, the camera will move a smaller distance and that could be throwing out some of your other calculations. Using Time.deltaTime won't improve your framerate, but it will make your game framerate independant, which is very important.

How to calibrate the size and speed of 3d objects

everyone
I am just starting with a new project in VR and have some problems.
I want to simulate a simple 3D-Ball like the real one in real world.
I am using OptiTrack to register my camera( 3d glasses) and Middle VR(free edition) to realize the 3D effect in 3D room. And also Unity for 3D models and programming with C#.
My Problem:
I have a real plastic ball and use it to compare with that 3D-Ball. If i go to the real ball in (real world) it will be bigger and if i go away from it, it will be smaller visually.
The 3d ball has the same diameter as the real one and stand at the same position. But if i go to ihm with 3d glasses it will be (quicker) bigger than the one in real world and if i go away from it, it will quick smaller than the real one...
Can anyone explain to me, how to solve the problem, what should i do. I need your help.
Thank you and have a nice day.
Carvin.
Get the size right inside unity. 1 unit in unity is 1 meter in real life.
Also play with the field of view of your maincamera in unity to get the desired result

Andengine A Moving Ball example, juddering / lag

In the Andengine "A Moving Ball" example, I experience a "jump" in the animation every 5 seconds or so ie. The lateral movement is not always smooth, it seems to skip a few pixels. I'm running this on a Samsung Galaxy SII. I also noticed this on the emulator.
A Moving Ball example
This is a problem for me as I'm creating an environment of ten bouncing balls and every few seconds I get this judder effect.
I'm looking for a very consistent movement, similar to say the baloons in "Crazy Pill":
Crazy Pill
Has anyone noticed this occassional lag or any idea how to create a smooth movement?
Thanks
see if this discussion and solution helps
Jittering texture when using BoundCamera