-
-
Save Lachee/338c91a72a5fe564fe22d1ec29fd1794 to your computer and use it in GitHub Desktop.
Rouigh guide for reddit post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DoorController : MonoBehaviour { | |
public void OnInteract() { | |
animator.SetTrigger("close"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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