- Home /
Xbox Controller ObjectArray Scripting Error
Hello, I'm currently setting up my Xbox Game Pad Controller to run my Unity game, using this script and tutorial I have successfully managed to access all the functionality of the Xbox controller: http://www.youtube.com/watch?v=J8HaAyLzPh4
My problem is this, before I had a script like this:
var Next : GameObject;
function OnMouseUp()
{
gameObject.active = false;
Next.active = true;
}
this worked fine with the Mouse Click but now when I want to change that to be triggered by the A Button, it didn't work, so I have written this script to try and fix that:
var Next : GameObject;
Input.GetButtonDown("360_AButton");
{
gameObject.active = false ;
Next.active = true ;
}
This gives me several compiling errors about moving colons and semicolons, I have been trying for the past few hours to get the sequence right but to no avail. Could someone please help? What am I doing wrong? The "360_AButton" is part of the Script provided above in the youtube link and all that works 100%.
Thank you.
Answer by FLASHDENMARK · Jul 30, 2012 at 11:29 AM
function Update() {
if(Input.GetButtonDown("360_AButton")){
gameObject.active = false;
Next.active = true ;
}
}
You have to check if you are pushing the button using an if statement. And you should also put the code into the Update function(or similar) so that it checks every frame if you push the button or not.
Thank you very much OrangeLighting! You have saved me hours of work.