Here is my code :
public int Limit;
public static float Speed = 10, X;
private Rigidbody rb;
void Start ()
{
rb = GetComponent();
Speed = Random.Range (5, 10);
Limit = Random.Range (100, 1000);
}
void Update ()
{
Vector3 pos = transform.position;
Debug.Log (transform.position.y);
}
void FixedUpdate ()
{
while (transform.position.y < Limit) {
rb.AddForce (0.5f, (Random.Range (100, 900)), 0 * Speed);
}
The problem is that unity crash, I think it's the "while" which can't stop, beacause it cannot acess to the transform.position . I would like to get the position x from my object to stop the AddForce when the limit is overtake.
I need help please
Thank's
↧