Here is my code for opening a door:
public class DoorOpenClose : MonoBehaviour
{
public Animator doorControl;
public Camera camera;
private bool _isOpen = false;
void Update()
{
if (Input.GetMouseButton(0))
{
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
RaycastHit raycastHit;
if (Physics.Raycast(ray.origin, ray.direction, out raycastHit, Mathf.Infinity))
{
_isOpen = !_isOpen;
doorControl.SetBool("isOpening", _isOpen);
}
}
}
}
This script is attached to a button which then opens and closes a door successfully, the only problem is that another button with the same script, which is attached to a separate door opens when I click on a button.
tldr: Button 1 plays an animation, but Button 2 plays the same animation. Both buttons have the same scripts.
I can not find an answer (due to me being a beginner at code).