- Home /
Unity 3D Gun Animation Errors
Hi there, i need help, i know a decent amount of Java, so i thought JS is near enough the same, but im having some problems, i want to make my guy have gun animations, but im getting these errors when running it in Unity.
Errors. vvv
Assets/Scripts/Player.js(19,1): BCE0044: expecting ), found '{'.
Assets/Scripts/Player.js(27,1): BCE0044: expecting EOF, found 'else'.
Here is my Code.vvv
#pragma strict
var PlayerState : int;
var PlayerAnimSec : GameObject;
function Update () {
PlayerStateController();
PlayerAnims();
}
function PlayerStateController()
{
if((Input.GetAxis("Vertical") !=0 || Input.GetAxis("horizontal") !=0 ))
{
if (Input.GetButton("Sprint")
{
PlayerState = 2;
}
else
{
PlayerState = 1;
}
}
else
{
PlayerState = 0;
}
}
function PlayerAnims()
{
if (PlayerState == 0)
{
PlayerAnimSec.animation.CrossFade("Idle Animation", 0.4);
}
else if (PlayerState == 1)
{
PlayerAnimSec.animation.CrossFade("Walk Animation", 0.4);
}
else if(PlayerState == 2)
{
PlayerAnimSec.animation.CrossFade("Sprint Animation", 0.4);
}
}
Answer by KiraSensei · Oct 02, 2012 at 09:43 PM
if (Input.GetButton("Sprint")
There is a ")" missing at the end.
Your code is weird just after this line : if the sprint button is pressed, playerState = 2, and if not, playerState = 1, and if not (????), playerState = 0.
There is only 2 possibilities here, not 3.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Animating A pistol Firing 0 Answers
The AnimationClip 'Running' used by the AnimationComponent 'corpse' must be marked as Legacy? 1 Answer
How To Get Current Animation Name 3 Answers
can someone show me how to play a death animation when a the game object is destroyed (javascript) 3 Answers