예제 #1
0
            } /* Awake() */

            private void OnEnable()
            {
                // log
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonCAVIAREntityBehaviour.HoldController.OnEnable() : begin"
                    );

                // preliminary
                if ((this._parent = this.GetComponentInParent <ApollonCAVIAREntityBehaviour>()) == null ||
                    (this._rigidbody = this.GetComponentInParent <UnityEngine.Rigidbody>()) == null
                    )
                {
                    // log
                    UnityEngine.Debug.LogError(
                        "<color=Red>Error: </color> ApollonCAVIAREntityBehaviour.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> ApollonCAVIAREntityBehaviour.HoldController.OnEnable() : end"
                    );
            } /* OnEnable()*/
예제 #2
0
            } /* Awake() */

            private void OnEnable()
            {
                // log
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonCAVIAREntityBehaviour.IdleController.OnEnable() : begin"
                    );

                // preliminary
                if ((this._parent = this.GetComponentInParent <ApollonCAVIAREntityBehaviour>()) == null ||
                    (this._rigidbody = this.GetComponentInParent <UnityEngine.Rigidbody>()) == null
                    )
                {
                    // log
                    UnityEngine.Debug.LogError(
                        "<color=Red>Error: </color> ApollonCAVIAREntityBehaviour.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;

                // log
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonCAVIAREntityBehaviour.IdleController.OnEnable() : end"
                    );
            } /* OnEnable()*/
예제 #3
0
            } /* Awake() */

            private void OnEnable()
            {
                // log
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonCAVIAREntityBehaviour.InitController.OnEnable() : begin"
                    );

                // preliminary
                if ((this._parent = this.GetComponentInParent <ApollonCAVIAREntityBehaviour>()) == null ||
                    (this._rigidbody = this.GetComponentInParent <UnityEngine.Rigidbody>()) == null
                    )
                {
                    // log
                    UnityEngine.Debug.LogError(
                        "<color=Red>Error: </color> ApollonCAVIAREntityBehaviour.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.FreezePositionX
                          | UnityEngine.RigidbodyConstraints.FreezeRotation
                          );
                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.ContinuousDynamic;
                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);

                // log
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonCAVIAREntityBehaviour.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> ApollonCAVIAREntityBehaviour.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.down * (PoV_height_offset / 100.0f)
                          ) + (
                          UnityEngine.Vector3.forward * (PoV_depth_offset / 100.0f)
                          );

                // log
                UnityEngine.Debug.Log(
                    "<color=Blue>Info: </color> ApollonCAVIAREntityBehaviour.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> ApollonCAVIAREntityBehaviour.InitController.OnEnable() : end"
                    );
            } /* OnEnable() */