Okay, so in my game when you press esc it comes up with the options, i added a rigidbody and box collider to the camera, so when you press esc the camera drops to the floor which looks really cool!, but there is a problem when i’m playing the game i can shoot straight and the character goes weird because of the camera rigidbody etc, how can i fix it, so when you press esc the camera has a rigidbody and collider and drops to the floor like what i said before,
Have you tried enabling your Box Collider and Rigidbody when escape is first pressed and then disabling when pressed again? Since enabling and disabling these two components is not possible there are two possible workarounds you could try. The first involves disabling your collider and setting your rigidbody to kinematic (therefore making it not driven by the physics engine). While this would be the most efficient way to do it, I’m not sure if it will actually work. If it does, I would do it like this:
private var esc : boolean = false;
private var rigid : Rigidbody;
private var coll : BoxCollider;
function Start () {
rigid = GetComponent(Rigidbody);
coll = GetComponent(BoxCollider);
rigid.isKinematic = true;
coll.enabled = false;
}
function Update () {
if (Input.GetKeyDown(KeyCode.Escape)) {
if (!esc) {
rigid.isKinematic = false;
coll.enabled = true;
esc = true;
} else {
rigid.isKinematic = true;
coll.enabled = false;
}
}
}
If that doesn’t work however, I would try destroying the rigidbody component and then using AddComponent every time you enter your escaped state. This won’t be very efficient, however it’s the only alternative I can think of.