I’m having problems detecting my iPod (3rd gen). My code is detecting the iphone 4 just fine, but not my ipod. (it doesn’t make the speed change in the following code):
Anyone know how to check which device is being used? I don’t want to use FixedUpdate (it makes my game more ‘jumpy’)
And i’ve tested these various speeds outside of this device detection logic and the speed changes on the device, so I know this logic here is not detecting my device.
Well, for one your first if statement contains the parameters for the else statement, so it will never check the else
Removing the innards:
if (iPhoneSettings.model == “iPhone” || iPhoneSettings.model == “iPod Touch”)
{
}
else if (iPhoneSettings.model == “iPod Touch”)
{
}
Not sure if there are other issues.
Although regarding having a movespeed modifier set based on device power, you should probably make your Reeling speed in units per second. Instead of adding += reelspeed every frame and trying to guess the framerate, set reelspeed to something in m/s and then do += reelspeed * Time.deltaTime;
Anything that should happen on a per frame basis that you want to be the same across framerates you should set it to a value in m/s instead of m/frame and then multiply it by Time.deltaTime. It’ll save you a lot of headache.
How might I use Time.DeltaTime with my code here? It seems to slow down my speed loop and I can’t really figure out how to make it move faster. (this takes place in the update method, and I don’t want to use fixed update because it makes my game jumpy. However in fixed update everything works at the right speeds)
if (ReelSpinning)
{
reelPosY -= ReelSpeed;
for (int x = 0; x < Symbols.Length; x++)
{
float symbolPos = reelPosY + (x * symbolHeight);
float wrappedPos = ResetSymbolPosOffset + Mathf.Repeat(symbolPos, Symbols.Length * symbolHeight);
Symbols[x].transform.position = new Vector3(ReelTopStartPosition.x, wrappedPos, ReelTopStartPosition.z);
//Reset symbols to default animation after they have reset position (changes default animation after (symbolHeight * 2) - 0
if (Symbols[x].transform.position.y <= 0 Symbols[x].transform.position.y > (symbolHeight * 2))
{
PackedSprite pSprite1 = (PackedSprite)Symbols[x].GetComponent(typeof(PackedSprite));
int defaultAnim = pSprite1.defaultAnim;
pSprite1.PlayAnim(defaultAnim);
}
}
}
adding Time.deltaTime will slow your movement WAY down, but the way to fix that is to increase the base constants.
Currently your reelSpeed is being used as meters per frame.
reelSpeed * Time.deltaTime is in meters per second.
If you wanted the identical speed as you currently do, and the current frame rate is 30 frames per second you need to increase the reelSpeed by 30x.
So crank up the base reelSpeed value by a factor of 10-30, and then change this line:
Symbols[x].transform.position = new Vector3(ReelTopStartPosition.x, wrappedPos, ReelTopStartPosition.z);
to
Symbols[x].transform.position = new Vector3(ReelTopStartPosition.x, wrappedPos * Time.deltaTime, ReelTopStartPosition.z);
When modifying the transform of any object within Update() modify anything that should be framerate independent right before setting in on the transform.
Edit: It will require some retweaking, but it means that it will move the same speed regardless of what the framerate/device is.