• 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 IKilledKenny_2 · Sep 12, 2014 at 08:35 PM · animationprojectile

Play Projectile at a certain animation frame

Hello Unity3D i have a question about projectiles with animation frames.How can i make it that a projectile that i have created plays at a certain frame of an animation that my character plays?for example my character does a roundhouse kick and the roundhouse animation has 10 frames how can i make it that when the animation hits the 10th frame a fire particle comes out of his leg?or i have another character that has guns and i want to make it that when he shoots (he also has 10 frames) at the last frame the bullet comes out of his gun? If anyone knows how to fix this problem.Can you please tell me how it can be corrected?

Also this is something i have tried to get the idea of what it needs in order for it to work

 var rocket : Rigidbody;  //our prefab
 var throwPower : float = 10; //power variable determines how fast this object will be "shot out"
  
 function Update () {
 
 if(animation["Shoot_combo_2"].time == 10){
 
  
 var clone : Rigidbody; //variable within a variable
  
 clone = Instantiate(rocket, transform.position, transform.rotation); //the clone variable holds our instantiate action
  
 clone.velocity = transform.TransformDirection(Vector3.forward * throwPower); //applies force to our prefab using the "forward" position times our throwPower variable
  
 }
  
 }

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
0

Answer by tanoshimi · Sep 12, 2014 at 08:37 PM

You might want to check out animation events: http://docs.unity3d.com/Manual/animeditor-AnimationEvents.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 IKilledKenny_2 · Sep 12, 2014 at 09:38 PM 0
Share

No i seen it before and for some reason i cant add an animation event i think it has something to do with the fact that i didnt make the animations in unity3D i made them in blender

avatar image
0

Answer by Cherno · Sep 13, 2014 at 03:09 AM

The simple way would be to have a "fireDelay" float variable that has a different value depending on the firing animation. When playing the animation, a timer would count upwards via time.deltaTime until the fireDelay threshold is reached, and only then is the projectile instantiated or whatever. CoRoutines help here.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

my animation script does not work 0 Answers

Blender Animation Looping Delay Problem 2 Answers

SpriteManager 2 1 Answer

Making a Tiled Animated Image With a Material 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