• 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 Fries · Feb 16, 2010 at 04:30 AM · collisionphysics

how to make objects collide and something happen?

hey everybody, I'm making a game where the character swings a sword. I am fairly new to unity and have read all the tutorials but i can't figure this out - when the character swings a sword at a box i want it to be destroyed. how can i do this? i have a "box destroyed" object and i want this to replace the regular box once the sword hits it. somebody help plz!

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

1 Reply

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

Answer by Ashkan_gc · Feb 16, 2010 at 04:57 AM

add a collider to your box and check it's "is trigger" property. create a script like this

OnTriggerEnter (other:collider)
{
if (other.name=="sword")
{
Instantiate (dsbox);
Destroy(this.gameObject);
}
}

you should define a variable dsbox on top of your script and drag your destroyed box object on to it in the inspector.

Comment
Add comment · Show 5 · 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 Fries · Feb 16, 2010 at 05:08 AM 0
Share

ok this helps, but can u plz be more specific - i really dont know anything about javascript. could you give me the exact script? THN$$anonymous$$ U

avatar image Ashkan_gc · Feb 16, 2010 at 10:05 AM 0
Share

i want to recommend you to read more first and know all APIs and then start creating a game. when i started learning unity, i read docs and code for 2 months and then started coding my first game. i read editor classes later. first learn the language from tutorials on the web and then unity's runtime classes and reference and manual and read tutorials and go and start make your great game.

avatar image Fries · Feb 16, 2010 at 08:32 PM 0
Share

any good links you recommend? dunno much about this stuff only 14

avatar image Ashkan_gc · Feb 17, 2010 at 03:56 AM 0
Share

go to www.unity3d.com/support and you can find documentation there. in documentation there are many other links to what i said. also you can go to resources page that is full of videos and example projects and tutorials. take a look at unity's blog and search for "getting started" you'll find a post with many videos.

avatar image jason · May 16, 2010 at 03:09 PM 0
Share

your "collider" should become "Collider", there's a capital in it.

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

1 Person is following this question.

avatar image

Related Questions

unity3d is meter units? meter to cm 1 Answer

I want my Player to have collision physics 1 Answer

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer

Moving a ball around a maze 3 Answers

Keep rotation when changing parent in Unity 3D 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