private void FixedUpdate() { if ((!init) & (ready)) { init = true; geoTransform = transform.GetChild(0).gameObject.transform; geoTransform.Rotate(new Vector3(0, angle, 0)); } else if (ready) { st.Translate(stdVelocity.x, stdVelocity.y); st.Translate(inheritedVelocity.x, inheritedVelocity.y); } }
/** * \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 Allows the player to control to main spaceship. * \param void * \return void */ private void FixedUpdate() { // get keyboard input float xMove = Input.GetAxis("Horizontal") * st.speed; float yMove = Input.GetAxis("Vertical") * st.speed; st.Translate(xMove, yMove); }
/** * \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)); }