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.
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.