My issue is that a game running smoothly on PC is running considerably slower on my LG G4. It is a 2D game and I am using 2D physics, moving objects with their rigid bodies. I am new to Unity but not programming and not video game design.
I have seen a lot of posts about worse performance on Android. In my case, the current project is so simple that is never dips below 60 FPS, according to the profiler. The closest issue I have found is this post:
It seems very similar to my problem, but the answer did not help me. Although it does seem to be delta time related, it’s selective. For example, I have timers with the following code:
void Update()
{
if (!paused && runTime < length)
runTime = Time.realtimeSinceStartup - startTime;
}
This is used as enemy spawn and bullet fire rate timers. It is the same on PC as it is on my phone. However, in the case of bullets:
void Start()
{
m_rigidBody = GetComponent<Rigidbody2D>();
m_rigidBody.velocity = velocity;
}
Velocity is the same both PC and the phone, but the bullets move MUCH slower on the phone. As a matter of fact, everything does. There’s even control for the player that, for reasons of how I handle input, I am moving in the Update() function. Here is a snippet:
if (playerPos.x < pos.x)
{
if (m_velocity < 0f)
m_velocity = 0;
m_velocity = Mathf.Clamp(m_velocity + acceleration, -maxVelocity, maxVelocity);
playerPos.x += m_velocity * Time.deltaTime;
if (playerPos.x > pos.x)
{
playerPos.x = pos.x;
m_velocity = 0f;
}
if (playerPos.x + halfWidth > levelBounds.max.x)
{
playerPos.x = levelBounds.max.x - halfWidth;
m_velocity = 0f;
}
}
From my understanding, Unity handles delta time in its physics. Perhaps physics is being updated fewer times per frame on the phone or something… I just really can’t figure out what I’m missing but it does almost feel like there’s a setting I’m unaware exists and I need to toggle a checkbox.