예제 #1
0
        /// <summary>
        /// Initializes the swimmer when they enter water
        /// </summary>
        public void EnterWater()
        {
            if (mIsInWater)
            {
                return;
            }
            mIsInWater = true;

            //mSavedIsGravityEnabled = mActorController.IsGravityEnabled;
            mActorController.IsGravityEnabled = false;
            mActorController.ForceGrounding   = false;

            //mSavedFixGroundPenetration = mActorController.FixGroundPenetration;
            //mActorController.FixGroundPenetration = false;

            mSavedInvertRotationOrder            = mActorController.InvertRotationOrder;
            mActorController.InvertRotationOrder = false;

            mSavedAllowPushback            = mActorController.AllowPushback;
            mActorController.AllowPushback = true;

            mSavedStance = mActorController.State.Stance;
            mActorController.State.Stance = EnumControllerStance.SWIMMING;

            if (mWaterSurface != null)
            {
                mWaterSurfaceLastPosition = mWaterSurface.position;
            }

            if (OnSwimEnter != null)
            {
                OnSwimEnter(this);
            }

#if USE_MESSAGE_DISPATCHER
            com.ootii.Messages.MessageDispatcher.SendMessage(mActorController.gameObject, "SWIM_ENTER", this, 0f);
#endif

#if USE_BONE_CONTROLLER
            Actors.BoneControllers.BoneController lBoneController = mActorController.gameObject.GetComponent <Actors.BoneControllers.BoneController>();
            if (lBoneController != null)
            {
                lBoneController.EnableMotors <Actors.BoneControllers.FootGround2BoneMotor>(false);
            }
#endif
        }
예제 #2
0
        /// <summary>
        /// Initializes the swimmer when they exit water
        /// </summary>
        public void ExitWater()
        {
            if (!mIsInWater)
            {
                return;
            }

            if (OnSwimExit != null)
            {
                OnSwimExit(this);
            }

#if USE_MESSAGE_DISPATCHER
            com.ootii.Messages.MessageDispatcher.SendMessage(mActorController.gameObject, "SWIM_EXIT", this, 0f);
#endif

#if USE_BONE_CONTROLLER
            Actors.BoneControllers.BoneController lBoneController = mActorController.gameObject.GetComponent <Actors.BoneControllers.BoneController>();
            if (lBoneController != null)
            {
                lBoneController.EnableMotors <Actors.BoneControllers.FootGround2BoneMotor>(true);
            }
#endif

            mIsInWater = false;

            // Jumping into water can cause us to save a bad value since the jump turns off gravity
            //mActorController.IsGravityEnabled = mSavedIsGravityEnabled;
            mActorController.IsGravityEnabled = true;
            mActorController.ForceGrounding   = true;

            //mActorController.FixGroundPenetration = mSavedFixGroundPenetration;
            mActorController.InvertRotationOrder = mSavedInvertRotationOrder;
            mActorController.AllowPushback       = mSavedAllowPushback;
            mActorController.State.Stance        = mSavedStance;

            mWaterSurface             = null;
            mWaterSurfaceLastPosition = Vector3.zero;
        }