Door Animation
- Keshav Batra
- Dec 10, 2021
- 1 min read
So I was actually able to get the door animation working only when I'm looking at it and I'm pressing E. This was initially a challenge for me, but it literally just came to me in my mind. I literally just played around with my code and this was the result.
if (Physics.Raycast(OpenRay, out hit, RayDistance))
{
Debug.DrawRay(Cam.transform.position, Cam.transform.forward * RayDistance, Color.blue);
if (hit.transform.CompareTag("Door"))
{
print("Door Was Detected");
}
if (Input.GetKeyDown(KeyCode.E) && hit.transform.CompareTag("Door"))
{
if (DoorClose)
{
DoorClose = false;
myDoor.SetBool("IsOpen", true);
}
}
Comments