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 Parzivell · Dec 12, 2014 at 09:14 AM · animationmecanimboolean

Mecanim Boolean

Hello, I've made an animation script for my character using the mecanim parameter, float. Now i need to use a Boolean and i don't think I'm using it correctly, I'm not getting any errors but It's just not working.

 #pragma strict
 
 var animator : Animator; //stores the animator component
 var v : float; //vertical movements
 var h : float; //horizontal movements
 var Sprint : float;
 var Shoot : boolean;
 
 function Start () 
 {
     animator = GetComponent(Animator); //asigns animator component when game is tarted
     
 }
 
 function Update ()
 {
     v = Input.GetAxis("Vertical");
     h = Input.GetAxis("Horizontal");
     Sprinting();
 }
 
 function FixedUpdate ()
 {
     //set the "Walk" parameter to the v axis value
     animator.SetFloat ("Walk", v);
     animator.SetFloat("Sprint", Sprint);
     animator.SetBool("Shooting", true);
 }
 
 function Sprinting ()
 {
     if(Input.GetButton("Sprint"))
     {
         Sprint = 0.2;
     }
     else
     {
         Sprint = 0.0;
     }
 }
 
 function Shooting ()
 {
     if(Input.GetButton("f"))
     {
         Shooting == true;
     }
     else
     {
         Shooting == false;
     }
 }
 

Comment
Add comment · Show 1
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 taxvi · Dec 12, 2014 at 09:21 AM 0
Share

it is well known that $$anonymous$$echanim is a rascal when it comes to changing variable types/names. Try deleting that variable and creating a new with a different name. then reapply it to all the animations. :| it sucks I know

1 Reply

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

Answer by Baste · Dec 12, 2014 at 09:37 AM

If the boolean variable Shooting didn't exist, you would be getting a warning message to the console when you set it to true. Something along the lines of "The boolean parameter Shooting does not exist"

If you're not getting any of those, there's something wrong in your transitions. It's easy to check - when playing, select the model that's being animated, open the animator window, and see what's happening. You'll see the variables changing in real time.

Now, what's happening is that if you just click 'f', then the shooting parameter will be true for just a couple of frames - maybe too few frames for you to actually notice the correct animation playing. I'd guess it's either that, or that you haven't set up the animator correctly.

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How can I change a mecanim animation by pressing a key? 1 Answer

Mecanim and trigger code 1 Answer

Detect input, return true for 3s then return false 1 Answer

Mecanim animation and scripting problems 0 Answers

In place animations using Mecanim and how to script it 2 Answers


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