} /* Awake() */ private void OnEnable() { // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.HoldController.OnEnable() : begin" ); // preliminary if ((this._parent = this.GetComponentInParent <ApollonMotionSystemCommandBehaviour>()) == null || (this._rigidbody = this.GetComponentInParent <UnityEngine.Rigidbody>()) == null ) { // log UnityEngine.Debug.LogError( "<color=Red>Error: </color> ApollonMotionSystemCommandBehaviour.HoldController.OnEnable() : failed to get parent/rigidbody reference ! Self disabling..." ); // disable this.gameObject.SetActive(false); // return return; } /* if() */ // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.HoldController.OnEnable() : end" ); } /* OnEnable()*/
} /* Awake() */ private void OnEnable() { // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.ResetController.OnEnable() : begin" ); // preliminary if ((this._parent = this.GetComponentInParent <ApollonMotionSystemCommandBehaviour>()) == null || (this._rigidbody = this.GetComponentInParent <UnityEngine.Rigidbody>()) == null ) { // log UnityEngine.Debug.LogError( "<color=Red>Error: </color> ApollonMotionSystemCommandBehaviour.ResetController.OnEnable() : failed to get parent/rigidbody reference ! Self disabling..." ); // disable this.gameObject.SetActive(false); // return return; } /* if() */ // save initial local rotation, intialize filter state & curent timepoint this._lerp_rotation_from = this._rigidbody.transform.localRotation; this._lerp_position_from = this._rigidbody.transform.position; this._angular_filter_state = this._linear_filter_state = UnityEngine.Vector3.zero; this._time_count = 0.0f; this._total_time = ( experiment.ApollonExperimentManager.Instance.Session.settings.GetFloat("trial_inter_sleep_duration_ms") - 250.0f ) / 1000.0f; this._bEnd = false; this._rigidbody.angularDrag = 1.0f; // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.ResetController.OnEnable() : end" ); } /* OnEnable() */
} /* Awake() */ private void OnEnable() { // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.IdleController.OnEnable() : begin" ); // preliminary if ((this._parent = this.GetComponentInParent <ApollonMotionSystemCommandBehaviour>()) == null || (this._rigidbody = this.GetComponentInParent <UnityEngine.Rigidbody>()) == null ) { // log UnityEngine.Debug.LogError( "<color=Red>Error: </color> ApollonMotionSystemCommandBehaviour.IdleController.OnEnable() : failed to get parent reference ! Self disabling..." ); // disable this.gameObject.SetActive(false); this.enabled = false; // return return; } /* if() */ // zero velocity, acceleration & enforce velocity this._rigidbody.AddForce(UnityEngine.Vector3.zero, UnityEngine.ForceMode.VelocityChange); this._rigidbody.AddTorque(UnityEngine.Vector3.zero, UnityEngine.ForceMode.VelocityChange); this._rigidbody.AddForce(UnityEngine.Vector3.zero, UnityEngine.ForceMode.Acceleration); this._rigidbody.AddTorque(UnityEngine.Vector3.zero, UnityEngine.ForceMode.Acceleration); this._rigidbody.velocity = UnityEngine.Vector3.zero; this._rigidbody.angularVelocity = UnityEngine.Vector3.zero; // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.IdleController.OnEnable() : end" ); } /* OnEnable()*/
} /* Awake() */ private void OnEnable() { // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.InitController.OnEnable() : begin" ); // preliminary if ((this._parent = this.GetComponentInParent <ApollonMotionSystemCommandBehaviour>()) == null || (this._rigidbody = this.GetComponentInParent <UnityEngine.Rigidbody>()) == null ) { // log UnityEngine.Debug.LogError( "<color=Red>Error: </color> ApollonMotionSystemCommandBehaviour.InitController.OnEnable() : failed to get parent/rigidbody reference ! Self disabling..." ); // disable this.gameObject.SetActive(false); this.enabled = false; // return return; } /* if() */ // initialize our rigidbody this._rigidbody.ResetCenterOfMass(); this._rigidbody.ResetInertiaTensor(); this._rigidbody.transform.SetPositionAndRotation(this._parent.InitialPosition, this._parent.InitialRotation); this._rigidbody.constraints = UnityEngine.RigidbodyConstraints.None; this._rigidbody.drag = 0.0f; this._rigidbody.angularDrag = 0.0f; this._rigidbody.useGravity = false; this._rigidbody.isKinematic = false; this._rigidbody.interpolation = UnityEngine.RigidbodyInterpolation.Interpolate; this._rigidbody.collisionDetectionMode = UnityEngine.CollisionDetectionMode.Discrete; this._rigidbody.AddForce(UnityEngine.Vector3.zero, UnityEngine.ForceMode.VelocityChange); this._rigidbody.AddTorque(UnityEngine.Vector3.zero, UnityEngine.ForceMode.VelocityChange); this._rigidbody.AddForce(UnityEngine.Vector3.zero, UnityEngine.ForceMode.Acceleration); this._rigidbody.AddTorque(UnityEngine.Vector3.zero, UnityEngine.ForceMode.Acceleration); this._rigidbody.velocity = UnityEngine.Vector3.zero; this._rigidbody.angularVelocity = UnityEngine.Vector3.zero; // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.InitController.OnEnable() : rigidbody initialized" ); // virtual world setup // - user dependant PoV offset : height + depth // - max angular velocity aka. saturation point // - CenterOf -Rotation/Mass offset --> chair settings // - perfect world == no dampening/drag & no gravity float PoV_height_offset = 0.0f, PoV_depth_offset = 0.0f; if (!float.TryParse(experiment.ApollonExperimentManager.Instance.Session.participantDetails["PoV_height_offset"].ToString(), out PoV_height_offset) || !float.TryParse(experiment.ApollonExperimentManager.Instance.Session.participantDetails["PoV_depth_offset"].ToString(), out PoV_depth_offset) ) { // log UnityEngine.Debug.LogWarning( "<color=Yellow>Warning: </color> ApollonMotionSystemCommandBehaviour.InitController.OnEnable() : failed to get current participant PoV_offset, setup PoV_offset (height,depth) to default value [ " + PoV_height_offset + "," + PoV_depth_offset + " ]" ); } /* if() */ this._rigidbody.centerOfMass = ( UnityEngine.Vector3.up * (PoV_height_offset / 100.0f) ) + ( UnityEngine.Vector3.back * (PoV_depth_offset / 100.0f) ); // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.InitController.OnEnable() : rigidbody configured with current user settings, going idle state" ); // change state this._parent.Bridge.Dispatcher.RaiseIdle(); // log UnityEngine.Debug.Log( "<color=Blue>Info: </color> ApollonMotionSystemCommandBehaviour.InitController.OnEnable() : end" ); } /* OnEnable() */