Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

iOS bug. transform.translate not working properly only on iOS builds

$
0
0
Hi, i am using a script which simulates a projectile, with coroutine. Script works perfectly on Unity Editor, Windows build, Android build, except on iOS builds. I have a public float called gravity. Depending on it's value, changes the velocity of projectile. Problem is that on iOS builds, value of gravity changes based on conditions on the script, but still, velocity of projectile remains same. Following is the part of script where i simulate projectile. @Hellium float gravity = 8; // this value increases over time IEnumerator SimulateProjectile() { // Calculate distance to target float target_Distance = Vector3.Distance(player.position, target.position); // Calculate the velocity needed to throw the object to the target at specified angle. float projectile_Velocity = target_Distance / (Mathf.Sin(2 * firingAngle * Mathf.Deg2Rad) / gravity); // Extract the X Y componenent of the velocity float Vx = Mathf.Sqrt(projectile_Velocity) * Mathf.Cos(firingAngle * Mathf.Deg2Rad); float Vy = Mathf.Sqrt(projectile_Velocity) * Mathf.Sin(firingAngle * Mathf.Deg2Rad); float elapse_time = 0; while (player.position.y >= 3.3f) { player.Translate(Vx * Time.fixedDeltaTime, (Vy - (gravity * elapse_time)) * Time.fixedDeltaTime, 0); elapse_time += Time.fixedDeltaTime; yield return null; } }

Viewing all articles
Browse latest Browse all 4709

Trending Articles