Trying to make my ship float up and down and it just isn’t working out, any ideas?
Error - UnityException: You are not allowed to call this function when declaring a variable. Move it to the line after without a variable declaration.
public class movementScript : MonoBehaviour {
public GameObject shipObject = GameObject.Find ("Default");
void Start () {
}
// Update is called once per frame
void Update () {
float playerPos = shipObject.transform.position.y;
if (playerPos == 0f || playerPos <= -0.11f) {
Vector3 upVector = new Vector3 (0.0f, 0.1f, 0.0f);
this.transform.Translate (upVector, Space.World);
}
else if (playerPos >= 0.11f){
Vector3 downVector = new Vector3 (0.0f, -0.1f, 0.0f);
this.transform.Translate (downVector, Space.World);
}
}
}