when i try to specify a maxHeight and minHeight the object Disappear.
using UnityEngine; using System.Collections;
public class AviaoControl : MonoBehaviour {
public GameObject aviao;
public float maxHeight;
public float minHeight;
public float positionX;
public float speed;
void Start () {
}
void Update () {
float translation = Input.GetAxis ("Vertical") * speed;
aviao.transform.Translate(0,translation,0);
if (aviao.transform.position.y > maxHeight) {
aviao.transform.position = new Vector2(0,maxHeight);
//Why the object disappear when enter here?
}
if (aviao.transform.position.y < minHeight) {
aviao.transform.position = new Vector2(0,minHeight);
//Why the object disappear when enter here?
}
}
}
the object move normally but, when it enter in if the object disappear in the game. The values max nad MinHeight are correct. I’m using unity 5.2