Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 aronatvw · Nov 23, 2013 at 02:57 PM · prefabanimatorstategameobject.find

Controlling Animator through Script. I'm stuck please help!

I have been digging at this problem for a while and would greatly appreciate some insight. This may be long I am trying to add as much detail as possible.

BG INFO:

I am making an infinite runner kind of like jetpack joyride. I am stuck on making an animation that plays to warn the player there is a nearby obstacle approaching.

WHAT I HAVE TRIED:

I was first using an animation script but decided to go with the Animator instead. With the Animator I use the change material referance to make a flashing icon and its attached to a plane. So my current obstacle is a prefab. when the prefab is created I use the,

obstacle = Gameobject.Find("obstacle"); anim = obstacle.Getcomponent(); anim.Play("StartAnim");

(Sorry if codes not perfect its a lot of code from different scripts thought I'd simplify it)

Then on the prefab I use a code saying

if(transoform.position.x < animationplanepos){ anim.Play("StopAnim"); }

So obviously I switch to a different Animator State. I would like to just start and stop the animator completely ass opposed to having it keep running guessing in the long run it would cut down on memory but I have tried and failed. Now I think I have read about this problem elsewhere but cant remember but after about the third or fourth prefab instantiate everything seems to be working fine.

QUESTIONS:

  1. Obviously, why doesnt the script work immediately but instead after 3 or 4 prefabs?

  2. Is there possibly an easier or more effective way of achieving this goal.

  3. I am also getting the "AnimationEvent has no function name specified!". In the add animation event window it doesn't give me an option to select a function I have no idea what this window is for.

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

0 Replies

· Add your reply
  • Sort: 

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

16 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

Related Questions

Prefab animation only plays on first instance 1 Answer

Can't find Animator State/Invalid Layer Index in child object inside prefab 0 Answers

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

Can't switch through 2 animation states in one frame 0 Answers

Enemy prefab's script won't keep inspector-applied settings. 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