Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Missing definitions and script error

$
0
0
This script makes an animated AI wander around a game object, however the console is displaying these errors and i have no idea how to fix them. ![alt text][1] [1]: /storage/temp/81165-capture.png Here's the script using UnityEngine; using System.Collections; public class RandomWander : MonoBehaviour { public GameObject init; private Transform initpos; private float time = 10; private bool update = true; public float radius; Animator anim; float lowX; float highX; float lowZ; float highZ; // Use this for initialization void Awake () { anim = gameObject.GetComponent (); initpos = init.GetComponent(); lowX = initpos.x - radius; highX = initpos.x + radius; lowZ = initpos.z - radius; highZ = initpos.z + radius; } // Update is called once per frame void Update () { if (update) { Vector3 pos = getRandomPos(); } gameObject.LookAt(pos); if (gameObject.transform.position == pos){ time -= Time.deltaTime; anim.SetBool("Walking", false); if (time <= 0.0f){ update = true; time = 10.0f; } } else { transform.position += transform.forward * 0.2f; anim.SetBool("Walking", true); } } Vector3 getRandomPos(){ Vector3 pos; pos.x = Random.Range(lowX, highX); pos.y = initpos.y; pos.z = Random.Range(lowZ, highZ); return pos; } } If anyone can resolve these issues it would be greatly appreciated.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>