Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by DJ_GRANDMA · Mar 24, 2017 at 06:14 AM · scripting beginneranimationsplayer movement

problem scripting walk/idle animations

*im by no means fluent in any code yet, just getting into c# with maybe 2 months experience in java. also new to unity, just trying to make things work to build a prototype 2d platformer through trial,
error, lots of research (though mostly dead ends) and hopefully the unity community.....

that being said, im trying to code in walk/idle animations in with the movement code in my PlayerMovement class like so....

 //LEFT
         if (Input.GetKey (KeyCode.A)) {
             rb.velocity = new Vector2 (-moveSpeed, rb.velocity.y);
 
         }// ANIMATION
 
         if (Input.GetKey (KeyCode.A)) {
             GameObject.Find("Player").GetComponent<Animator>.SetTrigger<"walk">;

ive set parameters in the animator between walking and idle ("walk" and "idle") monodevelop doesnt seem intuitive enough to tell me what im doing wrong as all im getting is a parser error on the end of the last line of that code. i know that i need to be putting something in the run or update functions to support the animator but because everybody does the same things differently im finding it extremely hard to figure out how to do this through research on here and elsewhere. i have a lingering suspicion i should be doing this in my blank Player class or in a separate Animation class or something? learning on your own can be so frustrating sometimes lol! thanks for reading. hopefully i wont be too embarrassed by this in the coming years!

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
0

Answer by hexagonius · Mar 24, 2017 at 09:19 AM

method calls always need brackets:

 GameObject.Find("Player").GetComponent<Animator>().SetTrigger<"walk">();
Comment
Add comment · Show 2 · 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 DJ_GRANDMA · Mar 25, 2017 at 02:15 AM 0
Share

@hexagonius thanks for responding! GameObject.Find("Player").GetComponent().SetTrigger<"walk">(); monodevelop doesnt like this, displaying Invalid expression term ')' in response. am i not understanding something here? ive figured out that i need to put this stuff in my player class, because its the class called in the animator window. im going over the scripting API documentation to get a better understanding of what im ai$$anonymous$$g for. any further direction or advice is appreciated!

avatar image hexagonius DJ_GRANDMA · Mar 25, 2017 at 10:04 AM 0
Share

thats not what I wrote, the code is still wrong

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

99 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Touch buttons sometimes won't work 0 Answers

How can I prevent the trail rendering when pressing a specific key via Script? 0 Answers

Creating Objects on Right Click to Navigate Around 0 Answers

Idle animation? 0 Answers

[Help] 2D sprite jelly-like animations with a script (Tweening) 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