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 $$anonymous$$ · Apr 05, 2014 at 03:42 PM · collisionphysicscolliderdeath

Very simple collision death

Hi guys, I need a little help with scripting. I'm not a coder myself, and since I'm a one man team it means the progression to coding is slow. I'm doing a game jam with a very simple game, and so far its going very well. However, I've come across a bit of a problem. I can't figure out how to (and also cannot find)a script which would basically mean if anything collides with my players collider, then the player gets destroyed. It would need to attach to only the head part of my character (on its rig), which has of course a collider and rigibody of its own. If anyone could help that would be fantastic. I know I should be more knowledgeable about coding and that it's annoying to have people come to you with questions without any knowledge of what it means, I completely get that, but I am learning, its just slow.

Thanks guys

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
0

Answer by Nequium · Apr 05, 2014 at 04:59 PM

This answer assumes that your character is made up of a bunch of different pieces, considering it has a "head part." Make sure the other objects that collide with your player have a collider of their own. Set all colliders to "Is Trigger." Add rigidbodies to your player and all objects that can kill it. Make sure "Use Gravity" is unchecked on all rigidbodies (unless you want to use gravity).

Create a new C# script. Add this code to the script BELOW the Update function. NOT inside of it:

//Drag your MAIN player object into the variable below AFTER you've attached this script to your player's head public Transform player; void OnTriggerEnter(Collider other) { Destroy(player.gameobject); }

Attach the script to your player's head. This should do the trick, if I correctly understand they way you have your player set up, which is that he has different objects making up his body, all children of a main object. If your player is just ONE object, simply change Destroy(player.gameobject); to Destroy(gameobject); and get rid of the player Transform variable.

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 $$anonymous$$ · Apr 05, 2014 at 07:02 PM 0
Share

EDIT: Oh, I fixed those past errors, for anyone getting error messages, make sure to put the code just before the last closed bracket, so it has to be inside $$anonymous$$onobehaviour but not the others inside of that

Thanks so much for all your help mate, I really needed that! If you need any models being done, I'll surely give it a shot

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Disable/Enable Colliders 1 Answer

No Collision 3 Answers

object goes through another object error 1 Answer

Do you have to have a rigidbody component for collision detection? 1 Answer

How to check if two objects are mutually ignoring collision? 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