Advice on how to make player crawl

Just wondering where I would start to get my character to crawl say inside a log? i have a model and the mesh is already done for the log he can run around it and jump on top of it but I’m trying to make it so when you go near the log he presses B and changes into a crawl position and goes through it without being able to stand up but able to move left,right,forward and back.

Step 1: Create new animations, say, Crouch_Walk, Crouch_Idle, Crouch_Quick. Crouch_Walk being the slow movement, Crouch_Idle being standing still, and Crouch_Quick would probably be a rare case, as crouching is usually coupled with slow movement. Now, I assume you have a normal walk and idle animation already, if not, you’ll need to make that too.

Step 2: Create a trigger area around the entrances to the log, big enough to listen for the whole player body. Next, write a script to listen for whether or not the player has gone into the trigger area, and if so, show to press B, along with changing your stance.

/* Save under CheckForCrouch.cs */
using UnityEngine;
using System.Collections;
using System;

public static class CrouchVars
{
	public static bool canCrouch = false, isCrouched = false, isIdle = true;
	// Do Not Change
	
	public static Animation[] animation_list;
	public static GameObject player;
	// Define these in your editor
}

private sealed class CheckForCrouch : MonoBehavior
{
	protected GameObject player = CrouchVars.player;
	private void Update()
	{
		if(isCrouched)
		{
			// If you're crouching, default to this animation
			if(!isIdle)
			{
				// If you're not idle, that means you're walking
				if(player.animation.clip !== CrouchVars.animation_list['Crouch_Walk'])
					player.animation.clip = CrouchVars.animation_list['Crouch_Walk'];
			}else{
				// If you're idle, set it to idle instead
				if(player.animation.clip !== CrouchVars.animation_list['Crouch_Idle'])
					player.animation.clip = CrouchVars.animation_list['Crouch_Walk'];
			}
			/*
			 More logic for normal walk and idle
			*/
		}
			
		if(!player.animation.clip.isPlaying)
			player.animation.clip.Play();
			// Loop animations as you move
	}
	
	private void OnTriggerEnter(Collision e)
	{
		// If you just entered the area
		if(e == CrouchVars.player)
			CrouchVars.canCrouch = true;
			// You can crouch
	}
	
	private void OnTriggerExit(Collision e)
	{
		// If you just left the area
		if(e == CrouchVars.player)
			CrouchVars.canCrouch = false;
			// You cant crouch
	}
}

This script has not been tested, but from writing it I believe it should. If it’s broken, the errors should be easy to fix. Attach the script to your trigger area, and add in your animations and your player object.

Hope this helps, good luck.