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 /
avatar image
0
Question by stephen_george98 · Jun 12, 2016 at 07:00 AM · animationanimatorplayerbooleanplayer movement

Make Animation Play After Boolean is Set to True?

Hello all,

I am pretty fluent in using Unity, but regarding Mechanim and Animations I am not the too great at currently, so please don't give me too much of a hard time lol. So I have this boolean that is in my GameManager script :

  public bool countDownDone = false;

This boolean gets set to true once my "3,2,1, GO!" Countdown Timer ends at the beginning of my game. Everything in my game starts after that boolean is set to true. Example:

 using UnityEngine;
    using System.Collections;
 
    public class PlaneMover : MonoBehaviour {

 private GameManagerScript GMS; // Reference to my GameManager Script

 public float scrollSpeed;
 public float tileSizeZAxis;
 public float acceleration; //This has to be a negative number in the inspector. Since our plane is coming down.
 
 private Vector3 startPosition;

 void Start () {

     GMS = GameObject.Find ("GameManager").GetComponent<GameManagerScript> (); //Finds the Script at the first frame

     // Transform position of the quad
     startPosition = transform.position;
 }
 
 void Update () {
     
     if (GMS.countDownDone == true) //Everything starts once the countdown ends. 
     {

         /* Every frame - time in the game times the assigned scroll speed 
             and never exceed the length of the tile that we assign */
         float newPosition = Mathf.Repeat (Time.time * scrollSpeed, tileSizeZAxis);

         // New position equal to the start position plus vector3forward times new position
         transform.position = startPosition + Vector3.forward * newPosition; // was vector3.forward

         scrollSpeed += Time.deltaTime * acceleration; // This makes the plane increase in speed over 
                                                       //  time with whatever our acceleration is set to.
 
     }
 }
 }

I have this Crawling animation that plays at the very beginning of the game (Even before the Timer ends) and loops forever. My question is , how do I make that crawling animation also start once that boolean is set to "true"? Or do I just apply it to a CoRoutine and make it play after 3 seconds? I have done extensive research on whether to reference Animation or Animator and I got confused on that too. Any advice? If you need more pictures or details on my question, just let me know. Thank you! :) alt text

animation.png (25.7 kB)
Comment
Add comment · Show 2
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 UsmanAbbasi · Jun 12, 2016 at 10:24 AM 1
Share

Post your animator controller screenshot with transitions and parameters.

avatar image stephen_george98 UsmanAbbasi · Jun 12, 2016 at 10:09 PM 0
Share

alt text

alt text

@UsmanAbbasi There are no transitions or parameters in this scene. That is the only Character Animation that is playing in the scene. It is on loop to keep on repeating itself. All of the movement I programmed to just be manipulated with the transform of the character.

animation-2.png (64.3 kB)
animation-3.png (53.9 kB)

2 Replies

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

Answer by UsmanAbbasi · Jun 12, 2016 at 10:28 AM

@stephen_george98 If there is only one state or even if you have more states this is the way you should delay the animations. You should deactivate the "Animator" component in inspector by default, then after the countdown ends activate the "Animator" component like this:

 public Animator animator;
 
 void StartAnimations()
 {
     animator.enabled = true;
 }

Pass animator reference in variable "animator" and call "StartAnimations()" function when countdown is completed.

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

Answer by husainhz7 · Jun 12, 2016 at 01:19 PM

Well you haven't posted a pic of your animation controller. But in there, you have to make a transition from an "idle" animation to your desired one. Then you need a Boolean parameter there which you can set in your code true when ever you need it.

Sorry if I'm not clear, ask my if you don't get it

Read more here: http://docs.unity3d.com/Manual/AnimationParameters.html

Comment
Add comment · Show 1 · 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 stephen_george98 · Jun 13, 2016 at 02:46 AM 0
Share

@husainhz7 I posted a picture of my animator controller above :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Jump animation anticipation 2 Answers

Blend Tree Transition Conditions. 0 Answers

Inputs and animations interfering with each other 1 Answer

Stop Animation State in Animator from Speeding Up after Playing it a Second Time? 0 Answers

2D Animation does not start 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