Example #1
0
        public Movement(GameObject obj, CharacterController _thisController, double _moveAcc = 0.05
                        , double _moveMax = 0.2, double _friction = 0.02, float _gravity = 9.81f)
        {
            thisObj        = obj;
            thisController = _thisController;

            moveAcc = _moveAcc; moveMax = _moveMax; friction = _friction;
            gravity = _gravity;

            motion                = new Vector2(0, 0);
            motionV               = 0;
            isMoved               = false;
            isMoveEnabled         = true;
            isFrictionEnabled     = true;
            isGravityEnabled      = true;
            isRetainMotionEnabled = false;

            prevMotionMagnitude = 0;
            prevMotionV         = 0;
            prevPosition        = new Vector3();

            profile = SaveProfile();
        }
Example #2
0
        public void LoadProfile(MovementProfile profile)
        {
            if (profile.moveAcc.HasValue)
            {
                moveAcc = profile.moveAcc.Value;
            }
            if (profile.moveMax.HasValue)
            {
                moveMax = profile.moveMax.Value;
            }
            if (profile.friction.HasValue)
            {
                friction = profile.friction.Value;
            }
            if (profile.gravity.HasValue)
            {
                gravity = profile.gravity.Value;
            }
            if (profile.isMoveEnabled.HasValue)
            {
                isMoveEnabled = profile.isMoveEnabled.Value;
            }
            if (profile.isFrictionEnabled.HasValue)
            {
                isFrictionEnabled = profile.isFrictionEnabled.Value;
            }
            if (profile.isGravityEnabled.HasValue)
            {
                isGravityEnabled = profile.isGravityEnabled.Value;
            }
            if (profile.isRetainMotionEnabled.HasValue)
            {
                isRetainMotionEnabled = profile.isRetainMotionEnabled.Value;
            }

            this.profile = profile;
        }