Pause state presets?

snicker

Member
Hello, I am making a pause screen. I have a state Paused State Preset on my character locomotion that sets Timescale to 0 when the pause UI activates. When the pause UI deactivates my character's Pause state is set to false.

It works fine except when I pause while the character is Airborne, then upon resuming the game he gets stuck in midair and this I get this error.

Right now the only parameter in the Paused CharacterLocomotionPreset is timescale = 0, I've tried changing a few others but to no avail. What should I do?



transform.position assign attempt for 'ShinobiFixedScale(Clone)' is not valid. Input position is { NaN, NaN, NaN }.
UnityEngine.Transform:set_position(Vector3)
Opsive.UltimateCharacterController.Character.CharacterLocomotion:ApplyPosition() (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:1415)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:ApplyPosition() (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:987)
Opsive.UltimateCharacterController.Character.CharacterLocomotion:UpdatePositionAndRotation() (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:542)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:UpdatePositionAndRotation() (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:825)
Opsive.UltimateCharacterController.Character.CharacterLocomotion:UpdatePositionAndRotation(Boolean) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:517)
Opsive.UltimateCharacterController.Character.CharacterLocomotion:OnAnimatorMove() (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:1471)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:OnAnimatorMove() (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1757)
 
I can't reproduce this within the demo scene. Here's the script I used:

C#:
using UnityEngine;
using Opsive.UltimateCharacterController.StateSystem;

public class Pause : MonoBehaviour
{
  bool paused;

  void Awake() {
    paused = false;
  }

  void Update() {
    if (Input.GetKeyDown(KeyCode.P)) {
      paused = !paused;
      StateManager.SetState(this.gameObject, "Pause", paused);
    }
  }
}
 
Thanks for the help. I got it working, I redid the event setup and stopped getting the error.
Code:
    public void GamePaused()
    {
        if (spawnedCharacter != null)
        {
            StateManager.SetState(spawnedCharacter, "Paused", true);
        }
        else
        {
            return;
        }
    }

    public void GameUnPaused()
    {
        if (spawnedCharacter != null)
        {
            StateManager.SetState(spawnedCharacter, "Paused", false);
        }
        else
        {
            return;
        }
    }
 
I can't reproduce this within the demo scene. Here's the script I used:

C#:
using UnityEngine;
using Opsive.Shared.StateSystem; // This change

public class Pause : MonoBehaviour
{
  bool paused;

  void Awake() {
    paused = false;
  }

  void Update() {
    if (Input.GetKeyDown(KeyCode.P)) {
      paused = !paused;
      StateManager.SetState(this.gameObject, "Pause", paused);
    }
  }
}

For anyone having the same problem, the import has actually changed.
 
Top