I want, at the beginning of the scene, for my object to appear at a random x value within a range. This is my simple code, and it’s not working and I don’t have an error… I know what I did wrong must be something simple, can I get some help?
using UnityEngine;
using System.Collections;
public class Upward : MonoBehaviour {
Vector3 velocity = Vector3.zero;
public Vector3 AntiGravity;
// Use this for initialization
void Start () {
int RandomInt = (int)Random.Range(-0.755f, 0.755f);
transform.position = new Vector3 (RandomInt, -3.4f, -1.5f);
}
// Update is called once per frame
void Update () {
if (transform.position.y <= 3.35) {
velocity -= AntiGravity * Time.deltaTime;
transform.position -= velocity * Time.deltaTime;
}
}
}