- Home /
How to Smooth X Axis Movement on Mobile Devices?
Hi,
I am working on an endless runner game for iOS and Android, and I am trying to simply scroll my background by at a consistent speed on the X Axis. I am currently using the below code for the background scrolling, and while the scrolling works, it is a little "jerky" and "stuttering" on iOS, and even more so on Android (I am testing using an iPhone 6, iPad Mini Retina, and Samsung Galaxy 4 Tab).
//This should stop Unity from trying to grab the Transform component of my gameobject each frame!
// I have dragged this gameobject into this variable in the inspector!
public Transform me;
void Update ()
{
//Make sure that scroll speed equals MissionControl's speed!
scrollSpeed = MCscript.speed;
//Move to the left, consistently!
me.Translate (Vector3.left * Time.smoothDeltaTime * scrollSpeed);
}
I've looked online and found a variety of different options to try and fix this problem, and none of them have worked for me, but it seems like almost all of them involve V Sync settings which I don't think I have control of on mobile. Can anyone help? Thanks in advance for your help, and let me know if you need anything else from me at all!
(Using Unity 5 Personal License on a MacBook Pro Retina 13inch Early 2015 model)
Hi Tanoshimi,
$$anonymous$$y camera doesn't move.
Sean
Answer by Halfbiscuit · May 06, 2015 at 11:50 AM
Update can be a bit varied in when it is called, for physics changes like this you can try using:
Under 'Project Settings -> Physics' you can change how often this function updates if you want a smoother change.
If this does not solve the issue and your frame rate is low on the mobile device then this issue will be hard to prevent. You may need to look into optimizing your game in that case.
Answer by SniperED007 · Jan 13, 2016 at 07:12 PM
you need to tell Unity to try use 60 FPS for iOS:
void Start()
{
Application.targetFrameRate = 60;
}
Your answer
Follow this Question
Related Questions
Having just one scene in the game: is it inefficient? 2 Answers
Is Gyroscope supported on all mobile Android iOS devices with a gyroscope? 3 Answers
Receiving UI/touch events while mobile soft keyboard is open 0 Answers
Can a iOS game camera have the Bloom optimized effect with clear flags = depth only? 0 Answers
Is it okay to store many player preferences for mobile? 1 Answer