/** * \brief Moves the GameObject with AI. * \param void * \return void */ private void FixedUpdate() { float deltaTime = Time.fixedDeltaTime; // when countDown reaches 0, change angle and reset countDown if (countDown <= 0) { countDown = Random.Range(minInterval, maxInterval); currAngleDelta = targetAngleDelta; targetAngleDelta = Random.Range(-angleVariance, angleVariance); angleDeltaDelta = (targetAngleDelta - currAngleDelta) / countDown; } else { countDown -= deltaTime; } // adjust angleDelta currAngleDelta += (angleDeltaDelta * deltaTime); // move forward surfaceTraveller.Rotate(currAngleDelta); surfaceTraveller.Translate(0, surfaceTraveller.speed); }
/** * \brief Places the GameObject on a sphere randomly. * \param void * \return void */ private void Start() { surfaceTraveller = GetComponent <SphereTraveller>(); float halfCir = (surfaceTraveller.Radius * Mathf.PI * Mathf.PI * 2) / Time.fixedDeltaTime; surfaceTraveller.Translate(Random.Range(-halfCir, halfCir), Random.Range(-halfCir, halfCir)); surfaceTraveller.Rotate(Random.Range(-180, 180)); }