Example #1
0
        /// <summary>
        /// Sets up the lean module on Unity Awake
        /// </summary>
        private void Awake()
        {
            controller = GetComponent <CharacterController>();
            leanModule = new PrioritizedControllerModule(0, Update_Lean);

            controller.Lean += (val) =>
            {
                if (unsetInstance != null)
                {
                    StopCoroutine(unsetInstance);
                }

                if (val)
                {
                    controller.AddModuleToUpdate(leanModule);
                    if (leanSettings.preventMovement)
                    {
                        controller.IsMovementBlocked = true;
                    }
                }
                else
                {
                    unsetInstance = UnsetLean();
                    StartCoroutine(unsetInstance);
                    controller.IsMovementBlocked = false;
                    controller.RemoveModuleFromUpdate(leanModule);
                }
            };
        }
Example #2
0
 /// <summary>
 /// Adds a module (if not already added) to the modulesUnderFixedUpdate collection
 /// </summary>
 /// <param name="module">The PrioritizedControllerModule to add</param>
 public void AddModuleToFixedUpdate(PrioritizedControllerModule module)
 {
     if (!modulesUnderFixedUpdate.Contains(module))
     {
         modulesUnderFixedUpdate.Add(module);
         modulesUnderFixedUpdate.Sort((x, y) => {
             if (x.priority < y.priority)
             {
                 return(1);
             }
             if (x.priority > y.priority)
             {
                 return(-1);
             }
             return(-x.method.ToString().CompareTo(y.method.ToString()));
         });
     }
 }
 /// <summary>
 /// Sets up the module on Unity Awake
 /// </summary>
 private void Awake()
 {
     swimModule = new PrioritizedControllerModule(10, FixedUpdate_Swim);
     controller = GetComponent <CharacterController>();
 }
Example #4
0
 /// <summary>
 /// Removes a module from the modulesUnderFixedUpdate collection
 /// </summary>
 /// <param name="module">The PrioritizedControllerModule to remove</param>
 public void RemoveModuleFromFixedUpdate(PrioritizedControllerModule module)
 {
     modulesUnderFixedUpdate.Remove(module);
 }