- Home /
Disable player input whilst a GuiTexture is enabled?
Hi, I'm trying to make it so that when I hit "e" on an object, a Guitexture appears (a piece of paper), the player can't move again, until he hits "e", in which case the paper is dismissed and movement regained. This is in Javascript, but the mouselook scripts are Unity's which are in C#. I would also not like the player to be able to move his character with the keyboard either. This is what I have so far:
#pragma strict
var ShowPaper : boolean = false;
var distance : float;
var maxDistance : float = 1.5;
var Player : GameObject;
var CameraObject: GameObject;
var GUITexture: GameObject;
function Start () {
Screen.showCursor = false;
}
function Update () {
if (Input.GetKeyDown ("e"))
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit) && ShowPaper)
{
GUITexture.guiTexture.enabled = false;
CameraObject.GetComponent("MouseLook").active = true;
Player.GetComponent("MouseLook").active = true;
Screen.lockCursor = false;
ShowPaper = false;
}
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
distance = hit.distance;
if (distance < maxDistance && hit.collider.gameObject.tag == "Paper")
{
GUITexture.guiTexture.enabled = true;
Screen.lockCursor = true;
CameraObject.GetComponent("MouseLook").active = false;
Player.GetComponent("MouseLook").active = false;
ShowPaper = true;
}
}
}
}
However, when I hit "e" on the object, the entire player is disabled (camera and all). Any help?
Your answer
Follow this Question
Related Questions
Android: How do you position GUITexture and GUIText according to different screen sizes (JS)? 2 Answers
What`s more expensive GUI Texures or Quads for displaying units health?(RTS) 1 Answer
Set Max Rotation On Weapon Sway 0 Answers
how to move object with joint 2 Answers
Best Way to make a character move 1 Answer