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 MythStrott · Aug 02, 2010 at 06:06 PM · delayanimation-end

How to create a delay so object isn't instantiated until after an animation finishes?

Hello I'm working on a RPG. I have a character finished (via Blender(great program)). The animation is done. I'm now trying to master the implementation of animation inside Unity.

My current problem is that when I have the player do the animation for making a campfire and then instantiating an instance of the campfire prefab, the campfire is created right when the animation starts. I don't want the campfire to be created until the animation is completed.

Is there some way I can either tell it to wait until the animation is done? Otherwise it would be good enough if I could just put a short delay in between the animation start and the campfire being instantiated.

Here is the code I have working right now:

var newObject : Transform;

function Update () { if (Input.GetButtonDown("Jump")) { animation.CrossFade ("MakeGround"); var creation = Instantiate(newObject, GameObject.Find("spawnPoint").transform.position, Quaternion.identity); } }

So what can I do?

Thank you very much.

If you want to see the game, I can upload my progress to my website. It would only take about 2 minutes.

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

2 Replies

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

Answer by 3dDude · Aug 02, 2010 at 06:19 PM

try this :

var newObject : Transform; var animationTime : float = 5;

     function Update () {

     if (Input.GetButtonDown("Jump")) {
     animation.CrossFade ("MakeGround");
     makeCampFire();

     }

     }

 function MakeCampFire () {
     yield WaitForSeconds(animationTime);
     var creation = Instantiate(newObject, GameObject.Find("spawnPoint").transform.position, Quaternion.identity);
 }

Comment
Add comment · Show 2 · 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 MythStrott · Aug 02, 2010 at 06:28 PM 0
Share

Thanks! Works perfectly. I had to adjust the ti$$anonymous$$g, but the script is great.

avatar image 3dDude · Aug 02, 2010 at 06:29 PM 0
Share

glad i could help =)

avatar image
-1

Answer by Flynn · Aug 02, 2010 at 06:26 PM

Unity 3 will be supporting animation events, so when it comes out, be sure to look those up too.

Comment
Add comment · Show 2 · 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 qJake · Aug 02, 2010 at 07:01 PM 0
Share

Uh... you mean these, that are already available with Unity 2.6.x? -- http://unity3d.com/support/documentation/Components/animeditor-AnimationEvents.html

avatar image Flynn · Aug 02, 2010 at 07:15 PM 1
Share

Haha, my bad. :P

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

No one has followed this question yet.

Related Questions

Better way to delay a function for a few seconds? Javascript 1 Answer

how do you add camera lag or delay for flight sim 1 Answer

Wait and fading script 1 Answer

adding a delay to shooting 2 Answers

Time.time button delay trick causing NaN 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