Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Vesmok · Dec 14, 2012 at 01:54 AM · animationerrorjava

Animation script error

So i followed a tutorial and typed up the code its hard to read the code from the tutorial cause its on youtube and im getting a couple errors.. heres my code:

 > function Start () {
 > 
 > }
 > 
 > function Update () { 	PlayerAnims
 > (); 	PlayerStateController (); 	
 > }
 > 
 > function PlayerStateController () {
 > 	if
 > (Input.GetAxis("Vertical"))
 > !=0 ||
 > Input.GetAxis("horizontal")
 > !=0)) 	{ 	if
 > (Input.GetButton ("Sprint"))
 > 	{ 	PlayerState = 3; 	}
 > 	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("Idleanimation",
 > 0.4);
 > 
 > 	} 	else if (PlayerState
 > == 2) 	{
 > 	PlayerAnimSec.animation.CrossFade("sprint
 > animation", 0.4);
 > 
 > 	} 	 }


and im getting these errors:

Assets/scripts/player.js(22,21): BCE0044: expecting :, found '='.

Assets/scripts/player.js(20,40): UCE0001: ';' expected. Insert a semicolon at the end.

Assets/scripts/player.js(20,9): BCE0043: Unexpected token: if.

Assets/scripts/player.js(18,78): BCE0043: Unexpected token: ).

Assets/scripts/player.js(18,40): BCE0043: Unexpected token: !=.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Adamcbrz · Dec 14, 2012 at 04:30 AM

First please make sure you insert your code into a code block before posting because its hard to follow along which will make alot of people just skipped past it.

It looks like you are missing a couple of semicolons.

 PlayerState = 1 
 
 AND
 
 PlayerState = 0
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vesmok · Dec 14, 2012 at 09:20 PM 0
Share

Adding the semicolons there did not affect anything it is still displaying the error messages

avatar image Adamcbrz · Dec 14, 2012 at 11:29 PM 0
Share

Ok I went through and added tried to debug your script I think this one should be error free. I had to guess at your variable declarations since you didn't include those.

var PlayerState : int = 0; var PlayerAnimSec : GameObject;

function Start () {

}

function Update () { PlayerAnims(); PlayerStateController(); }

function PlayerStateController () { if(Input.GetAxis("Vertical") || Input.GetAxis("horizontal")) { if(Input.GetButton ("Sprint")) { PlayerState = 2; } else { PlayerState = 1; } } else { PlayerState = 0; } }

function PlayerAnims () { if(PlayerState == 0) { PlayerAnimSec.animation.CrossFade("idleanimation", 0.4); } else if (PlayerState == 1) { PlayerAnimSec.animation.CrossFade("Idleanimation", 0.4); } else if (PlayerState == 2) { PlayerAnimSec.animation.CrossFade("sprint animation", 0.4); } }

avatar image clunk47 · Dec 15, 2012 at 12:41 AM 0
Share

You need to EDIT your question and FOR$$anonymous$$AT your code correctly.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why isn't my java code working? 2 Answers

Making an animation play when you press down 2 keys 1 Answer

Why wont my animations play? 1 Answer

SCRIPT NOT WORKING 2 Answers

Console Error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges