- Home /
a problem on pausing player in ufps
I'm trying to pause the player movement while in chat.
if(in_chat == true)
{ m_Player.AllowGameplayInput.Set(false); }
the problem i'm facing here is, while firing or moving when i press chat button AllowGameplayInput is set to false but the player is still on the previous state(moving or running)before the button press...
A simple solution would be to not allow chat to start if player is in moving or running state, or have it go into a idle state when the AllowGameplayInput is set to false.
I do not know enough about your system to provide any better solution.
Answer by TonyLi · Dec 11, 2013 at 02:22 PM
I had to implement the same thing for Ultimate FPS support in the Dialogue System for Unity. It sets the player's state to "Freeze". (See the UFPS manual's States section.) Here's a code snippet from the Dialogue System:
/// <summary>
/// Freeze the UFPS player (i.e., gameplay) and show the mouse cursor.
/// </summary>
public void Freeze() {
if (fpController != null) {
fpController.SetState("Freeze", true);
fpController.Stop();
}
if (fpPlayerEventHandler != null) {
savedCrosshair = fpPlayerEventHandler.Crosshair.Get();
fpPlayerEventHandler.Crosshair.Set(null);
}
if (fpCamera != null) fpCamera.SetState("Freeze", true);
if (fpInput != null) fpInput.enabled = false;
if (hideHUD && (fpHUD != null)) fpHUD.enabled = false;
ShowCursor();
}
/// <summary>
/// Unfreeze the UFPS player (i.e. gameplay) and restore the previous cursor state.
/// </summary>
public void Unfreeze() {
if (fpController != null) fpController.SetState("Freeze", false);
if (fpPlayerEventHandler != null) fpPlayerEventHandler.Crosshair.Set(savedCrosshair);
if (fpCamera != null) fpCamera.SetState("Freeze", false);
if (fpInput != null) fpInput.enabled = true;
if (hideHUD && (fpHUD != null)) fpHUD.enabled = true;
RestorePreviousCursorState();
}
its working. But after freezing my character, weapon gets rotated for my mouse movement and also while jumping if a player presses the chat key he remains still in the air because of freezing the controller state.
Answer by PICHU · Dec 12, 2013 at 07:13 AM
hi thanks toni, i fixed it.
if(in_chat == true)
{
// FreezePlayer();
m_Player.AllowGameplayInput.Set(false);
m_Player.Attack.Stop();
m_Controller.Stop();
}