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 WorldLink · Aug 14, 2013 at 06:54 AM · variabletransitionparameters

Speed won't work as a parameter

Hello. I'm trying to make my idle animation transition into walking animation for my character. I have a custom character and I'm controlling it with the 3rd person controller script that comes with unity.

The only real problem that I'm facing is that when I try to set Speed as a float parameter in the animator (as Unity tutorials suggest) and move my character, the float doesn't change, making it useless as a parameter.

I'm rather confused, since I was led to believe that Speed with a capital 'S' accesses some variable somewhere in Unity that keeps track of the speed of your character.

Is there something I need to change, or do I need to write the script that keeps track of the speed myself?

Comment
Add comment · Show 3
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 vexe · Aug 14, 2013 at 06:58 AM 0
Share

There's no such thing as " Speed with a capital 'S' accesses some variable somewhere in Unity that keeps track of the speed of your character." - that's just a variable, name it whatever you want. There must be something you're doing wrong, did you make sure you got your transition states set up correctly? - Try and debug, is your script changing the variable?

avatar image WorldLink · Aug 14, 2013 at 07:28 AM 0
Share

Ah, Ok. It turns out that I was just entirely disillusioned about how the system works; I'm brand new to Unity. I think I'll write a script that updates a variable to measure speed and use that as my parameter.

avatar image vexe · Aug 14, 2013 at 08:14 AM 0
Share

Checkout the $$anonymous$$ecanim tutorials on youtube, there's many. There's one from Unity official. They also have one for their S$$anonymous$$lth game tutorial series, good series for intermidates. Good luck.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by verenion · Aug 14, 2013 at 09:39 AM

"Speed" is not a special variable of any kind. You could call it "ThisIsMyVaraibleThatSaysHowFastIGo". I think the issue, is that you have't written a script that changes this. Something like this should work:

 void Start()
 {
     
     // get the animator
     animator = GetComponent<Animator>();
         
 }


 void Update()
 {

     // your speed is either +1, 0, -1 depending on if you are going forward
     // or backwards. This may change depedning on how you control your character
     float inputSpeed = Input.GetAxis("Vertical");

     // set the float for the speed value
     animator.SetFloat("Speed", inputSpeed);
 
 }

That is a C# script. This then needs to be attached to the gameobject in your scene that has the animator attached.

Comment
Add comment · Show 5 · 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 WorldLink · Aug 14, 2013 at 05:56 PM 0
Share

Will there be any conflict if there are both C# scripts and JS scripts attached to one object?

avatar image WorldLink · Aug 14, 2013 at 05:56 PM 0
Share

Also, thank you very much for the example script!

avatar image WorldLink · Aug 15, 2013 at 01:42 AM 0
Share

By the way, I think you meant to write inputSpeed ins$$anonymous$$d of playersCurrentSpeed in the SetFloat method.

avatar image verenion · Aug 15, 2013 at 09:17 AM 0
Share

Nope, they are compiled anyway, it makes no difference. Sorry, inputSpeed is actually from my game, I was supposed to rename it to playersCurrentSpeed to make it more clear. If this answer helps, upvote it and make it an an answer! If you need any more help, just let me know.

avatar image WorldLink · Aug 15, 2013 at 06:26 PM 0
Share

Ugh, not enough reputation.

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

17 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Another way to reference scripts? 2 Answers

Assigning varaibles to prefabs 1 Answer

Declaring Variable in Child & Access as Parent 2 Answers

Change variable value of a script from another script. both in different Game object 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