// Use this for initialization void Start() { GameObject tempObj = Instantiate(carObjs[Random.Range(0, carObjs.Length)], transform.position, Quaternion.identity) as GameObject; tempObj.name = "CarModel"; tempObj.transform.parent = transform; carMover = tempObj.GetComponent <carMovementS>(); carMover.RotateRandom(); }
// Use this for initialization void Start() { GameObject tempObj = Instantiate(carObjs[Random.Range(0, carObjs.Length)], transform.position, Quaternion.identity) as GameObject; tempObj.name = "CarModel"; tempObj.transform.parent = transform; carMover = tempObj.GetComponent <carMovementS>(); maxSpeed = randomMaxSpeed + Random.Range(-randomMaxSpeedRange, randomMaxSpeedRange); int RandomPath = Random.Range(0, numberOfPaths); path = iTweenPath.GetPath("Path" + RandomPath.ToString()); totolLenght = iTween.PathLength(path); speed = maxSpeed; lastPos = transform.position; iTween.PutOnPath(gameObject, path, 0.0f); iTween.LookTo(gameObject, iTween.PointOnPath(path, 0.001f), 0.0f); obstacle = GetComponentInChildren <UnityEngine.AI.NavMeshObstacle>(); }