Function not responding to GetKeyDown
I am trying to make a first/third person game but when ever i click the key i c or any other key i set it to it doesn't respond.
pragma strict
var FPScamera : Camera;
var Tpcamera : Camera;
private var camswitch : boolean = false;
function start()
{
FPScamera.GetComponent(Camera).enabled = true;
Tpcamera.GetComponent(Camera).enabled = false;
}
function update()
{
if(Input.GetKeyDown("c"))
{
camswitch = !camswitch;
}
if(camswitch == true)
{
FPScamera.GetComponent(Camera).enabled = false;
Tpcamera.GetComponent(Camera).enabled = true;
}
else
{
FPScamera.GetComponent(Camera).enabled = true;
Tpcamera.GetComponent(Camera).enabled = false;
}
}
Is the script and gameobject enabled? Everything else works as supposed to? Also try $$anonymous$$eycode.C ins$$anonymous$$d of "c".
All the game objects are enabled and everything working fine except this scripted. I dont know if its something else in the script. Its has changed a lot when i was using it back in 2012.
Answer by hexagonius · Jan 23, 2016 at 10:11 PM
function Start()
function Update()
camelcase
Your answer
Follow this Question
Related Questions
Rotate camera when colliding 0 Answers
How get position from a game object? 5 Answers
How to make a first-person player for my game (like slender or the island demo) 4 Answers
Please help me with my mouse pointer 0 Answers
How can I get my camera to follow a clone after a certain trigger occurs? 2 Answers