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 kidrockkenny · Jun 09, 2012 at 02:08 PM · animationobjectdestroyspawn

destroying object after animation

Hi i made a tree model and with it i have a animation of the tree falling down. when i play the tree falls down instantly like its sappose to but i need the tree to not play the animation until the user hits the tree a few times and i want the model to play the falling down animation then instantly delete the tree and put a new model in that place of the tree (which will be logs). how would i do all of this in order so it looks like players are choping the trees down?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by kolban · Jun 09, 2012 at 02:17 PM

Unfortunately, the sum goal of what you ask is going to be beyond a response on Unity Answers which is more focused on providing specific guidance to specific and focused Unity usage questions. At a high level, it sounds like you will need to understand Unity in total including:

  • Animation

  • Colliders

  • Triggers

  • Game Object lifecycle

The overall flow of your scenario sounds like:

Create your trees as being Game Objects with Rigid Bodies defined as Kinematic. When your player strikes the tree, an OnCollision() event will occur which can be used to determine that the tree was struck. You will also be told the force of the strike if that is of value to you. Each tree instance would have a private property defining the tree's "health". The health would be reduced for each strike. When the health reaches zero, then the animation for the tree falling would be played. Associated with the animation would be an Animation Event that would be associated with a function callback which would be invoked towards the end of the animation. The function could then execute a Destroy() command to destroy the Game Object.

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 Datael · Jun 09, 2012 at 02:23 PM 1
Share

Nice and thorough response and about the best guide you're going to be able to find for such a vast question as this!

avatar image
0

Answer by Datael · Jun 09, 2012 at 02:14 PM

The first thing you want to do is turn off Play Automatically on the animation component on your tree model. Then using some amount of code combined with colliders (depends exactly how you want it to recognize that someone's cut the tree down) get it at some point to fire off the animation.

At the top of the animation window where you can see the keyframe icons you can also add Animation Events. Using these you can call a method in a script that destroys a specific target object; you can also use an Animation Event to spawn the extra models that you want.

I can't write much more specifically than this because there's quite a few ways to go about it, but I hope this will point you in the right direction.

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
0

Answer by vjoseph · Jun 09, 2012 at 02:20 PM

Switching to logs could be something like this (pseudo code)

 Mesh logsMesh = something...
 MeshFilter treeMeshFilter = treeGameObject.GetComponent(typeof(MeshFilter)) as MeshFilter;
 treeMeshFilter.mesh = logsMesh; 


Someone else could answer the other part of the question.

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.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Destroy Object during animation 2 Answers

Spawning an object with entering a trigger. 0 Answers

Need help with enemy spawner 2 Answers

Object won't instantiate at parents position(solved) 2 Answers

Como activar una animacion al hacer clic en un objeto (How to activate an animation when you click on an object) 1 Answer


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