Skip to content

Instantly share code, notes, and snippets.

@Lachee
Created January 30, 2023 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lachee/338c91a72a5fe564fe22d1ec29fd1794 to your computer and use it in GitHub Desktop.
Save Lachee/338c91a72a5fe564fe22d1ec29fd1794 to your computer and use it in GitHub Desktop.
Rouigh guide for reddit post
public class DoorController : MonoBehaviour {
public void OnInteract() {
animator.SetTrigger("close");
}
}
public class InteractController : MonoBehaviour {
void Update() {
if (Input.GetKeyDown(KeyCode.E)) {
RayCastHit hit;
if (Phsics.Raycast(transform.position, transform.forward, out hit, 3f, doorsLayerMask)) {
var interactable = hit.collider.GetComponent<DoorController>();
interactable.OnInteract();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment