Cannot get rigidbody constraint to unfreeze

public class Items : MonoBehaviour
{
Rigidbody rb;

		public bool sweatBandsItem = false;

		// Use this for initialization
		void Start () 
		{
			rb.GetComponent<Rigidbody> ();
		}

		// Update is called once per frame
		void Update () 
		{
			if (sweatBandsItem == true) 
			{
				gameObject.FindWithTag("PushZone") = RigidbodyConstraints.None;
			}

		}
	void OnTriggerEnter(Collider other)
	{
		if (other.gameObject.CompareTag("SweatBands"))
		{
			other.gameObject.SetActive (false);
			sweatBandsItem = true;
		}

	}
	}

I’m having issues with unfreezing the position of a rigidbody. What I’m specifically trying to do is have my character able to push a cube after picking up an item (which I have working) and then unfreezing the rigidbody positions of all cubes with the tag “PushZone”. I’ve tried several approaches and the one I’ve posted above was the last attempt. The vast majority of google searches have led me to outdated methods, and the few that weren’t outdated simply didn’t work for me. Any advice would be appreciated.

Hi @tcrouch

Here we will need two private variables.

    private GameObject GO;
    private Rigidbody RB2;
    {

     void Start()
     {
       //First we will find all the gameObjects whose tag is 'PushZone'.

       GO=GameObject.FindGameObjectWithTag("PushZone");

       //Then we will get the Rigidbody Component that is attached to the gameObjects
          which are having 'PushZone' tag.

       RB2=GO.GetComponent<Rigidbody>();
     }
    
    void Update()
    {
       // Whenever you want to unfreeze..
       if(sweatBandsItem == true)
       {
           RB2.constraints=RigidbodyConstraints.None;
       }
       
    }

}

Whatever code is written in the Start method can be put in any method as per your desire.
I mean, if you want to Unfreeze only after picking up an item, then simply paste that code (Start Method Code) right after the “picking up code”.

Hope it will work.!