So I have the 2D Tutorial from the Unity website, and I’m trying to create a more simple toggle between characters. I’d like to press the “t” key and be able to toggle between lerpz and the spaceship (with no camera interaction. I have them both on screen at once, I don’t need the camera to follow either one.
Here is what I have:
var target : Spaceship;
var target2 : PlatformerController;
function Update () {
if (Input.GetKeyDown("t") target.canControl == false){
target.canControl = true;
target2.canControl = false;
}
if (Input.GetKeyDown("t") target.canControl == true){
target.canControl = false;
target2.canControl = true;
}
}
when I press “t” nothing happens. Though, when I set the second it statement to GetKeyDown(“y”) instead, then it works. Why can it not have “t” in both GetKeyDown statements?
I’m not sure what you mean by “active” and “cutting off all the scripts”, but I switched to using else and it did work. I should have thought of that to begin with, but I’m a scripting noob so I’m still getting used to how things work.