private void OnMouseOver() { Distance = PlayerCast.distanceFromTarget; if (Distance <= 5) //and the distance between player and object is less than 3 units { Disp.text = ("Press Button"); if (Input.GetButtonDown("Action")) //If (player presses E) { GetComponent <GameObject>(); GetComponent <Animation>().Play("Press1"); GetComponent <AudioSource>().Play(); print("Button1Pressed"); Puzzle1Script.Button1Pressed(); if (Puzzle1Script.order == 1) { print("1toBlue"); rend1.sharedMaterial = buttonMaterial1[1]; // blue } } } else if (Distance > 5) { Disp.text = ""; } }
private void OnMouseOver() { Distance = PlayerCast.distanceFromTarget; if (Distance <= 5) { Disp.text = ("Press Button"); if (Input.GetButtonDown("Action")) { GetComponent <GameObject>(); GetComponent <Animation>().Play("1Press6"); GetComponent <AudioSource>().Play(); print("Button6Pressed"); Puzzle1Script.Button6Pressed(); if (Puzzle1Script.order == 5) { rend6.sharedMaterial = buttonMaterial6[1]; // blue print("6toBlue"); } } } else if (Distance > 5) { Disp.text = ""; } }
void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Piece") { Debug.Log("Hit Piece"); Puzzle1Script otherPiece = other.GetComponent <Puzzle1Script>(); switch (direction) { case Direction.right: if (otherPiece.direction == Direction.left) { counter--; Debug.Log("True " + Time.time); Debug.Log(counter); } break; case Direction.down: if (otherPiece.direction == Direction.up) { Debug.Log("True " + Time.time); counter--; Debug.Log(counter); } break; } } }
void Start() { lmanager = GameObject.Find("ScriptBlock").GetComponent <LevelManager>(); interaction = 0; pc3d = GameObject.Find("Player3D").GetComponent <PlayerControls3d>(); try { p1s = GameObject.Find("Puzzle1").GetComponent <Puzzle1Script>(); } catch { } }