- Home /
'GetAxis' is not a member of 'function(): void'
Hi all,
I getting this error message when I try to use this code:
function Update() {
//...
v = Input.GetAxis("V1");
h = Input.GetAxis("H1");
//...
}
It says: 'Assets/Scripts/Entity/Player/NewPlayerControl.js(163,27): BCE0019: 'GetAxis' is not a member of 'function(): void'.'
I have coded my movement script and everything worked fine, till I needed to make the script accessible for two players. To spare code I decided to implement this:
if( isPlayer1 ) {
v = Input.GetAxis("V1");
h = Input.GetAxis("H1");
duckButton = Input.GetButtonDown("DUCK1");
dashButton = Input.GetButtonDown("DASH1");
jumpButton = Input.GetButtonDown("JUMP1");
attackButton = Input.GetButtonDown("ATK1");
defendButton = Input.GetButton("DEF1");
} else {
v = Input.GetAxis("V2");
h = Input.GetAxis("H2");
duckButton = Input.GetButton("DUCK2");
dashButton = Input.GetButton("DASH2");
jumpButton = Input.GetButton("JUMP2");
attackButton = Input.GetButton("ATK2");
defendButton = Input.GetButton("DEF2");
}
After this I get these errors. My other movement script works just fine. Any suggestions? Maybe I overlooked something very simple...
$$anonymous$$aybe you have a function Input()
defined in your script...?
Answer by benni05 · May 06, 2014 at 01:09 PM
Your v and h variables need to be declared outside of a function if they are used in more than one function which is most likely the case here. If they are just used in the Update method they need to be declared before using them:
var v = Input.GetAxis...