Hi guys so i have my randomwalk script that assigns values on x,z. It works fine when on lvl ground but i want to be able to assign a y value for up and down but unless y is 60 or near he will not move. How can i get this script to work for x,y and z?
using UnityEngine;
using System.Collections;
public class randomwalk : MonoBehaviour {
private Transform myTransform;
private NavMeshAgent agent;
bool sight=true;
int search=0;
bool ready=false;
int randy = 0;
float Addd = 0f;
float Addd2 = 0f;
int addd3=10;
Vector3 Ad = new Vector3 (0, 0, 0);
public Transform center;
int randy2 = 0;
int height=60;
bool wander = false;
void Awake() {
myTransform = transform;
}
void Start() {
agent = GetComponent<NavMeshAgent> ();
//Debug.Log (center.position);
}
// Update is called once per frame
void Update () {
wander = true;
if (wander==false){return;}
if (sight == true)
{ randy = Random.Range (-300, 300);
randy2 = Random.Range (-300, 300);
sight = false;
ready=true;
}
if (ready == true) {
Addd = center.position.x + randy;
Addd2=center.position.z + randy2;
Ad = new Vector3 (Addd, height,Addd2);
agent.SetDestination (Ad)
ready = false;agent.speed=2;
}
if ((myTransform.position.x - Ad.x < 10) && (myTransform.position.x - Ad.x > -10) &&
(myTransform.position.z - Ad.z < 10) && (myTransform.position.z - Ad.z > -10)) {
sight = true;
}
}
}