Question by
Dog-Gamer · May 06, 2016 at 01:22 AM ·
javascriptprogramming
Why wont this work?
It is suppose to have the player crouch once touching a tag with Hide! Any help?
#pragma strict
public var hidden = false;
public var hid_ready = false;
function OnCollisionEnter(Col: Collision) {
//Checking if touching box collider with tag "Hide"
if (Col.gameObject.tag == "Hide")
{
//Stopping going through the floor by changing var, wait until they are out to make hid_ready = true
if (hidden == false && hid_ready == false)
{
transform.localPosition = Vector3(0, -0.5, 0);
hid_ready = true;
hidden = true;
//Adding a hiding script
}
}
}
function OnCollisionExit(Col: Collision)
{
if (hidden == true && hid_ready == true)
{
hidden = false;
hid_ready = false;
//Code for returning the player camera back
transform.localPosition = Vector3(0, 0, 0);
}
}
function Start () {
}
function Update () {
Cursor.visible = true;
}
Comment
Your answer
Follow this Question
Related Questions
What is causing the object to fly upwards? 1 Answer
Wondering script Javascript 0 Answers
';' expected. Add semicolon at the end. 2 Answers