Basically I need help with getting my thing to be turned False if the raycast is not on it
This is the interactor
[
if (Input.GetKey(KeyCode.E))
{
InteractWithObjectRHold();
holdR = true;
}
else
{
holdR = false;
}
void InteractWithObjectRHold()
{
RaycastHit hit;
Ray ray = new Ray(cam.transform.position, cam.transform.forward);
if (Physics.Raycast(ray, out hit, 2f, Clothes))
{
Clothes Cloth = hit.collider.GetComponent<Clothes>();
Debug.Log("Searching");
Cloth.test(holdR);
}
}] cb
Here is the other script
[ void Update()
{
if (Timer > 0 && count)
{
Debug.Log("Found");
Timer -= Time.deltaTime;
}
else if (Timer <= 0 && count)
{
print("done");
ClothManage cManager = GetComponentInParent<ClothManage>();
cManager.clothesChecked++;
Destroy(gameObject);
}
else
{
// Reset state or perform other actions when not hit by raycast
ResetState();
}
}
public void test(bool bada)
{
count = bada;
if (count)
{
Debug.Log("do");
}
else
{
Debug.Log("don't");
}
}
public void ResetState()
{
count = false;
}]cb
I know it has something to do with the interaction script but I can't figure it out. Can someone quickly help please?