Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 sacajawhoohoo · Aug 02, 2015 at 08:07 AM · animationanimatornot workingpause

Unable To Pause Animations

Hello, I am currently using this script:

 private var enter : boolean;
 var target : GameObject;
 
 function Update ()
 {
     if(enter)
     {
         target.Animator.speed = 0;
         
     }
 }
 
 function OnTriggerEnter (other : Collider)
 {
     if (other.gameObject.tag == "Player") 
     {
         enter = true;
     }
 }

And I am receiving this error:

 NullReferenceException: Object reference not set to an instance of an object
 Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
 Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
 Boo.Lang.Runtime.RuntimeServices.SetProperty (System.Object target, System.String name, System.Object value)

Now I have never tried to pause an animator before and I am using unity 5, would I need to call something along the lines of: "target.getComponent..speed = 0;"?

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 sacajawhoohoo · Aug 02, 2015 at 01:36 PM 0
Share

Ive tried other various ways now, such as just using: Animator.enable and Animator.active, with all the same results. I know I am using the script on an object that has an animator attached, what could be the issue?

avatar image mtdrume · Aug 02, 2015 at 06:21 PM 1
Share

I have not used Animator much but does Animator.StartPlayback resume from Animator.StopPlayback ?

avatar image mtdrume · Aug 02, 2015 at 06:23 PM 1
Share

But also, maybe try changing the line target.Animator.speed = 0; to this.Animator.speed = 0;

2 Replies

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

Answer by sacajawhoohoo · Aug 02, 2015 at 07:24 PM

I figured it out, I was not using GetComponent first... Its times like this when I feel dumb, well here is the code for anyone who sees fit to need it:

 private var enter : boolean;
 var target : GameObject;
 
 function Update ()
 {
     if(enter)
     {
         target.GetComponent(Animator).enabled = false;
     }
 }
 
 function OnTriggerEnter (other : Collider)
 {
     if (other.gameObject.tag == "Player") 
     {
         enter = true;
     }
 }
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
1

Answer by moriggi · Aug 02, 2015 at 06:25 PM

Hello I think to pause the Animator component is not possible. Like other components of GameObject you can make nameOfComponent.enable = false. The Animator component is used to assign animations to a GameObject in your scene. You can create a new state of the controller make a transition in both directions and assign the speed in the inspector to 0 and run this state in the script.You have to change the script, it seems to me that you are using the Boo language!

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 sacajawhoohoo · Aug 02, 2015 at 07:11 PM 0
Share

how would I go about using enabled though? Ive tried multiple times now with the same result: "target.Animator.enabled = false;" "Animator.enabled = false;" and I even have tried the speed method Drumedia said in his comment "target.Animator.speed = 0;" and even "Animator.speed = 0;" I might just be missing something trivial here :/

avatar image sacajawhoohoo · Aug 02, 2015 at 07:19 PM 0
Share

because theoretically just saying "enabled = false" would work for what im trying to achieve, i just cannot get it to.

avatar image mtdrume · Aug 02, 2015 at 07:26 PM 1
Share
 gameObject.GetComponent<Animator>().enabled = false;

or

 gameObject.GetComponent<Animator>().StopPlayback();


should do it.

avatar image sacajawhoohoo · Aug 02, 2015 at 07:37 PM 0
Share

I posted my nswer right before yours, that or I did not see yours, you get a thumbs up in any case for your outstanding help.

avatar image mtdrume · Aug 02, 2015 at 07:56 PM 0
Share

haha thanks ;) i was 2 $$anonymous$$utes slow! $$anonymous$$y answer is C# lol

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

24 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

Related Questions

Animation doesn't play 1 Answer

Set up Animator with specific seconds 1 Answer

Animation in android game not working 2 Answers

What is the difference between 'Animator' & 'Animation'? 1 Answer

Animation playing in editor but not on android 0 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