You will need to do custom scripting, but you can add it on as another component - no need to edit AC's scripts.
AC's Mecanim implementation is written to give the designer more control than the Legacy system: AC provides parameters for the main states such as moving, talking, etc, but the rest is down to the designer.
Place your crouching animation(s) inside your Animator controller, and hook it up such that calling a Trigger or Bool parameter (or whatever makes sense in your game) causes it to fire. Then attach a custom script to your player that fires this parameter based on input. Be sure that you also check that the game isn't paused or in a cutscene. An example script would be something along the lines of:
If you're relying on AC's motion controller, it's better to go with a custom script or animation to more easily control things like the player's movement speed.
Such a script is included, however, in the "Player prefab: First Person" package available on the Downloads page. Alternatively, it's on the wiki here.
I understood your question - I'm advising that you're better off using an add-on script I've written.
Whether you can use PM for crouching would be a question for PM's developer - you'd need to control both the size of the Player's collider, and their walkSpeedScale component value. A raycast check above their head while crouched should also be made to make sure they can't stand if there's no room to.
Follow the instructions as they are on the wiki, except for the second bullet point (mentioning "Camera Parent"), and the note about setting the "Movement method" to "First Person".
If you have trouble, share screenshots so that we can see how things are.
I am recently trying to use trigger and Action list to Make player leave Crouchstate to the Standing/Idle/Walk.
there are some zones in the scene that i do not want my player to go there in Crouch state. in fact the reason is this zones are leading to couple of scenes which are not well friendly with Crouch state and crouch-State Capsule Collider so i want to force this change. in these Scenes i disabled Crouching , Jumping and Running.
I tried to Enable/Disable Player Prefabs Capsule Colliders and also Animation Bool through action list but it seems a very inaccurate and ineffective way of dealing with it.
In fact when my charachter hits a trigger , before Cam.Fadeout and Scene switch , I Make crouch bool False, And enable Walk Capsule ,Disable Crouch Capsule. but when the player goes there, even though he looks like standing walk/idle, but sill the movement and colliders are in state of Crouching.
I tried gpt to see if it can make me a costume action for that but got compiler errors .
using UnityEngine;
using AC;
namespace AC
{
[System.Serializable]
public class ActionPlayerStand : Action
{
public bool forceStand = true;
public ActionPlayerStand()
{
this.isDisplayed = true;
category = ActionCategory.Custom;
title = "Player: Force Stand";
description = "Forces the player to return to standing posture.";
}
public override float Run()
{
if (KickStarter.player != null)
{
PlayerCrouch crouchScript = KickStarter.player.GetComponent<PlayerCrouch>();
if (crouchScript != null)
{
crouchScript.SendMessage("Stand", forceStand);
}
}
return 0f;
}
public override void ShowGUI()
{
forceStand = EditorGUILayout.Toggle("Force Stand even if blocked?", forceStand);
}
public override string SetLabel()
{
return forceStand ? "Force Stand (True)" : "Force Stand (False)";
}
}
}
using AC;
using AC.Templates.FirstPersonPlayer;
[System.Serializable]
public class ActionPlayerStand : Action
{
public override ActionCategory Category { get { return ActionCategory.Player; } }
public override string Title { get { return "Force stand"; } }
public override float Run()
{
if (KickStarter.player)
{
FPCrouch crouchScript = KickStarter.player.GetComponent<FPCrouch>();
if (crouchScript)
{
crouchScript.Stand();
}
}
return 0f;
}
}
Comments
AC's Mecanim implementation is written to give the designer more control than the Legacy system: AC provides parameters for the main states such as moving, talking, etc, but the rest is down to the designer.
Place your crouching animation(s) inside your Animator controller, and hook it up such that calling a Trigger or Bool parameter (or whatever makes sense in your game) causes it to fire. Then attach a custom script to your player that fires this parameter based on input. Be sure that you also check that the game isn't paused or in a cutscene. An example script would be something along the lines of:
void Update ()
{
if (GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>().gameState == GameState.Normal)
{
if (Input.GetButton ("Crouch"))
{
GetComponent <Animator>().SetBool ("IsCrouching", true);
}
else
{
GetComponent <Animator>().SetBool ("IsCrouching", false);
}
}
}
Be sure to add "using AC;" to your script's header, too.
can i do this in playmaker?
If you're relying on AC's motion controller, it's better to go with a custom script or animation to more easily control things like the player's movement speed.
Such a script is included, however, in the "Player prefab: First Person" package available on the Downloads page. Alternatively, it's on the wiki here.
i mean can i use PM for crouching?
I understood your question - I'm advising that you're better off using an add-on script I've written.
Whether you can use PM for crouching would be a question for PM's developer - you'd need to control both the size of the Player's collider, and their walkSpeedScale component value. A raycast check above their head while crouched should also be made to make sure they can't stand if there's no room to.
can the script be used on third person controller without any mods?
The wiki script should work for AC's Direct movement mode as well, yes - assigning the "Camera Parent" field in the Inspector is optional.
man need help ... which part should i ignore or add
Follow the instructions as they are on the wiki, except for the second bullet point (mentioning "Camera Parent"), and the note about setting the "Movement method" to "First Person".
If you have trouble, share screenshots so that we can see how things are.
I am recently trying to use trigger and Action list to Make player leave Crouchstate to the Standing/Idle/Walk.
there are some zones in the scene that i do not want my player to go there in Crouch state. in fact the reason is this zones are leading to couple of scenes which are not well friendly with Crouch state and crouch-State Capsule Collider so i want to force this change. in these Scenes i disabled Crouching , Jumping and Running.
I tried to Enable/Disable Player Prefabs Capsule Colliders and also Animation Bool through action list but it seems a very inaccurate and ineffective way of dealing with it.
In fact when my charachter hits a trigger , before Cam.Fadeout and Scene switch , I Make crouch bool False, And enable Walk Capsule ,Disable Crouch Capsule. but when the player goes there, even though he looks like standing walk/idle, but sill the movement and colliders are in state of Crouching.
I tried gpt to see if it can make me a costume action for that but got compiler errors .
using UnityEngine;
using AC;
Try this: