Crouch Script Problem

Hello, I have a problem, at this script, and i want: when i am crouched and i have an object up above my head to be still Crouched. How i can do that?

using UnityEngine;
using System.Collections;

public class CrouchScript : MonoBehaviour {


    CharacterController controller;
    public bool Crouch;

    void Start ()
    {
        controller = GetComponent<CharacterController>();
    }
   
    void Update ()
    {
        if (Input.GetButton("Crouch"))
        {
            controller.height = 1.45f;
            Crouch = true;
        }
        else
        {
            controller.height = 2.9f;
            Crouch = false;
        }
    }
}

Check above your character with a raycast before you un-crouch.

1 Like

I Solved :)) but thanks anyway.