06-05-2014 01:22 PM
06-05-2014 02:10 PM
06-05-2014 02:53 PM
Though, you should always be careful about any time you take over control of the camera (i.e scripted animations) as they can cause some people discomfort.
////////////////////////////////////////////
public float heightStand;
public float heightCrouch;
public bool forceCrouch = false;
//////////////////////////////////////////
forceCrouch = false;
heightStand = Controller.height;
heightCrouch = 0.5f;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "CrouchZone") {
forceCrouch = true;
print ("zone hit!");
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "CrouchZone") {
forceCrouch = false;
print ("zone left!");
}
}
if (forceCrouch) {
Controller.height = heightCrouch;
print ("forceCrouch:" + forceCrouch);
} else {
Controller.height = heightStand;
print ("forceCrouch:" + forceCrouch);
}
06-08-2014 10:02 AM
06-08-2014 12:33 PM
"DillonRobinson" wrote:
Wow! So I was using if (forceCrouch = true) {} else {}
All I did was remove the "=true" and it started working! Very bizarre. I could have sworn they both meant the same thing.
06-08-2014 12:59 PM
"drash" wrote:
To simply check equivalence, use a double equal sign instead. The reason it works without the "= true" is because everything inside the if's parentheses are evaluated to a true/false condition.
06-10-2014 03:29 AM
06-11-2014 12:22 PM