Hello. How can I disable script in another gameobject? I am making a physic game, where you must drag elements, like triangles to get ball to the basket. After you drag elements, you can press “StartPhysic” button to make all draggable elements dynamic. How can I disable “MouseDragScript” in all elements after pressing “StartPhysic” button? I tried my best with just one component, unity doesn’t show any errors but it obviously doesn’t work. Here is my “StartPhysic” code. Thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StartPhysic : MonoBehaviour
{
public Rigidbody2D[] rBodies;
public GameObject element;
// Start is called before the first frame update
public bool phisicDisabled = true;
//Player.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Static;
public void OnMouseUp()
{
foreach (Rigidbody2D item in rBodies)
{
item.bodyType = RigidbodyType2D.Dynamic;
}
element.GetComponent<MouseDrag>().enabled = false;
}
}