I am not sure where to place these variables. Where it currently is, this is causing random crashes. Where it is commented out, there are no crashes but it is giving me strange performance, almost as if the speed increases over time or something strange. Where is the correct place for this variable? I also tried placing it outside of FixedUpdate completely and it just does nothing. Thanks!
var rotateState1 : boolean = false;
var rotateState2 : boolean = false;
function FixedUpdate ()
{
//var rotateSpeed : float = Time.deltaTime * 75.0;
//var rotateSpeed2 : float = Time.deltaTime * 100.0;
if (rotateState1 == true)
{
var rotateSpeed : float = Time.deltaTime * 75.0; // This one
transform.Rotate(0, rotateSpeed, 0);
}
if (rotateState2 == true)
{
var rotateSpeed2 : float = Time.deltaTime * 100.0; /// And this one
transform.Rotate(0, rotateSpeed2, 0);
}
}// FixedUpdate END
The code itself looks OK and wouldn’t cause any crashes by itself, so you probably have some interaction with other scripts. Although you should only use FixedUpdate for physics; use Update instead.
No, you’re directly altering the transform. Physics is stuff like AddForce etc., that uses the physics engine.
Yes, you always need to use Time.deltaTime to achieve framerate-independent movement (unless the input is already framerate-independent, such as mouse movement).
Thank you very much for the info. I changed my FixedUpdates to Update, still got the crash. Unplugged the ipad and rebooted the game and it doesn’t crash while not hooked up to Xcode. Not really sure what the deal is there, but it seems to only happen while still plugged in. Overall runs better in Update either way, fixed the choppiness.
I face similar issues too… This is my code… Is this a Unity bug?
public class Rotator : MonoBehaviour {
[SerializeField] float speed;
[SerializeField] int direction=1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate(Vector3.forward * speed * Time.deltaTime * direction);
}
}
I don’t know about you guys but it took me about 1 or 2 game freezes to realize to just exit my game from the device after I build it with Xcode. I also immediately exit Xcode just in case. I really don’t like Xcode haha such a pain compared to Android development which seems perfectly set up for Unity.
It seems like Xcode is pretty finicky and will cause game breaking freezes non stop even if the game runs perfectly fine in the Unity Editor.
Not sure if it’s a mistake to ignore xcode debug but no way I’m gonna try to get the game ready for that to not freeze until maybe right before release. Seems the game works fine xcode is just being a figurative cry baby with our code.