Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var AC : Animator;
- var InputKey = "Action";
- var Text = "Door";
- var DoorState = false;
- var ScriptObject : GameObject;
- var PlayerCollision = false;
- var TextDisplay : GameObject;
- function Start () {
- AC = ScriptObject.GetComponent("Animator");
- }
- function Update (){
- if (DoorState == false) {
- CloseTheDoor();
- }
- if (DoorState == true) {
- OpenTheDoor();
- }
- if (PlayerCollision == true) {
- if (Input.GetButtonDown(InputKey)) {
- if (DoorState == false) {
- DoorState = true;
- }
- if (DoorState == true) {
- DoorState = false;
- }
- }
- }
- }
- function OnTriggerStay (col : Collider) {
- if (col.gameObject.tag == "Player") {
- TextDisplay.GetComponent.<Text>().text = Text;
- PlayerCollision = true;
- }
- }
- function OnTriggerExit (col : Collider) {
- if (col.gameObject.tag == "Player") {
- TextDisplay.GetComponent.<Text>().text = "";
- PlayerCollision = false;
- }
- }
- function OpenTheDoor () {
- AC.SetBool("isopen", true);
- }
- function CloseTheDoor () {
- AC.SetBool("isopen", false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement