• 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 loizos-95b · May 05, 2019 at 07:25 PM · cameratriggerbool

How to add WAKE_UP animation before the character enters IDLE state?

Hi, i have a character in my game on which I want to execute the animation "Wake Up", before the I can move the object around. I think the way my Animator Controller handles that is incorrect. I have two BOOL parameter isAwake and isIDLE which I handle though C# scripts. See scripts below:


Script for character:

 private void Start () {
 
         //Store GameObject's Components
         animator = GetComponent<Animator>(); //Get Animator Controller
         controller = GetComponent<CharacterController>(); //Get Character Controller
         rb = GetComponent<Rigidbody>(); //Get Rigid Body
         MyCameraPrefab = Camera.main; 
         EffectsAudioSourceController = GetComponent<AudioSource>(); //Set Audio
 
         animator.SetBool("isAwake", false);
         animator.SetBool("isIDLE", false);
 }

 // Update is called once per 
 private void Update () {

     /* (RE)SET ANIMATION - IDLE */
     if (animator.GetBool("isAwake") == true && animator.GetBool("isIDLE") == true)
     {
         Animation_IDLE();
     }
 
 //CALL THIS FROM ANOTHER SCRIPT
 public void Animation_WakeUP() {
         animator.SetBool("isIDLE", false);
         animator.SetBool("isAwake", true);
 }

 public void Animation_IDLE() {
      animator.SetBool("isIDLE", true);
 }



Then i want a specific moment on where all the animations should begin. For example a camera object will move around as shown in the example here. When the animation of the camera ends, the TriggerWakeUP() function is called, which then call the Animation_WakeUP().

 public class DialogueTrigger1 : MonoBehaviour {
 
     public Dialogue dialogue;
     public GameObject playerPrefab;
     public Animator playerAnimator;
     
     public void TriggerWakeUP() {
 
         FindObjectOfType<DialogueManager>().StartDialogue(dialogue);
         FindObjectOfType<Movements>().Animation_WakeUP();
     }
 }

As you can see from the provided link this will execute the animation as soon as the player is loaded. How to prevent this, so that i can call the beginning of animation at any point?

alt text

untisafv2tled.png (24.8 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 loizos-95b · May 05, 2019 at 07:43 PM 0
Share

Or can i set a different animator ?

avatar image galactichyperstar · May 05, 2019 at 09:44 PM 0
Share

Do you really need the parameters? Can't you just get rid of the parameters and set an exit time ins$$anonymous$$d?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tomashu · May 06, 2019 at 01:17 AM

The default state, the orange one, is the state the animator starts in when it is entered - in your case when it is created.

So you'll have to add another state that has an empty animation as the default state if you don't want it to do anything at all until isAwake is set.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

181 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 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

Can't click gameobject when over another trigger? 1 Answer

Active camera on Start 1 Answer

camera detect collision 2 Answers

Camera movement causing UI Pointer Enter/Exit triggers to break? 0 Answers

Is it bad to add a mouse Lock at MouseLook Script? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges