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 AFoerster · Nov 08, 2013 at 09:43 AM · animationcollisiondestroy objectswordleftmouseclick

Set asset as weapon with animation and destroying other assets on impact

I'm an art student who's new to Unity and I thought I'd make my first project for a senior thesis class. The project is due when we come back from the weekend but google + the unity site have not been useful. I've been trying to find what I need for weeks. Any time I find a lead or code that should work it doesn't or I'm not sure where to put it. I have minimal coding experience. Simpler code and showing me where to put it is much appreciated. I still have a lot of other homework to do and I don't want my entire weekend going to this.

The game is of a pretend art gallery I've compiled in to Unity. The different artworks are .fbx, .obj, .blend, and .3ds (only one of these) files. I have the first person controller module with a child model called umbrellawanimation.blend. As the name says there is an animation on it I managed to import, but can't get to work. This animation is for the umbrella to swing like a sword, and I want it to play on the left mouse click.

I want to use the umbrella to destroy the artworks it encounters, touches, or collides with. A particle emit or explosion would be an added bonus. So far the umbrella only goes through everything or starts veering off in some random direction. I think I read somewhere I can do an OnCollission code and sort all of the artwork by a tag. This doesn't seem to work or I'm missing a component of either the artwork or the umbrella. As far as I know I've set some form of a collider and a rigidbody on everything.

I was using the script provided in the learning area modified to fit my game. What I have below was added to my umbrella as a script component.

 #pragma strict
 
 function OnCollisionEnter (col : Collision)
 {
     if(col.gameObject.tag== "Artpiece")
     {
         Destroy(col.gameObject);
     }
 }

Whoever can help me get this done in time would be my hero! If anyone can also direct me to something about proximity specific audio (audio only starts within a certain distance of an object and can only be heard in that area), that would be awesome! In the mean time I'll keep trying and work on a menu and such. I want this playable before I mess with extras. I apologize for asking for so much in so little time. I'm hoping when I try another game I'll learn from this one and spend more time on it.

I'm using version 4.2.2


Update!

I managed to get the destroy on collision to work! I set my umbrella as the trigger and worked a destroy on collision entry code from a site example. I may fiddle with a delay if I have time after audio.

Here's the code I implemented. I put it on my umbrella (tagged: weapon). Any work I wanted destroyed (which included defaults and all components was labeled Artpiece)

 var thing : GameObject;
      
     function OnTriggerEnter (other : Collider) {
      
     if( other.gameObject.CompareTag ("Artpiece" ))
     {
     Destroy(other.gameObject);
     }
      
 }
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

15 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

Related Questions

Swinging a sword without an animation... 1 Answer

How should I go about making nine custom sword swings that are appended to the number pad keys? 0 Answers

Animations: just making sure my workflow is right. 1 Answer

On collision play animation 1 Answer

How can I destroy an object if it touches NOTHING 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