Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Julian-Dicken · Jan 30, 2016 at 04:38 PM · unity 5collidernot working

Colliding doesnt work

I am makign a fps game so i wanted to create explosive barrels. I have a collider which hast the tag is trigger active and a collider ( a bit smaller than the other) which hasnt this active ... here is my code ...

using UnityEngine; using System.Collections;

public class ExplosionScript : MonoBehaviour { public GameObject Barrel; public GameObject Explosion; // Use this for initialization void Start () {

 }
 
 // Update is called once per frame
 void Update () {
 
 }
 void  OnTriggerEnter(Collider col)
 {
     if (col.tag == "Bullet")
     {
         Explosion.active = true;
        
         Destroy(Barrel);
     }
 }

}

Unfortuneatly this isnt working ... pls help XD

Comment
Add comment · Show 1
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 Julian-Dicken · Jan 30, 2016 at 04:48 PM 0
Share

btw need help quick XD

1 Reply

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

Answer by softrare · Jan 30, 2016 at 04:56 PM

I always use OnCollisionEnter http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html

Make sure all game objects involved in the collision have Colliders attached. At least 1 of them needs a non-kinematic rigidbody attached.

And just because you are new let me explain:

To make sure OnCollisionEnter is executed put in there a print("Boom!") so that you know that if not everything you want is happening (because of other possible coding mistakes) that still my advice was correct.

Please try it out and mark this answer as accepted if it worked.

Comment
Add comment · Show 4 · 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 softrare · Jan 30, 2016 at 05:02 PM 0
Share

non-kinematic rigidbody requirement added

avatar image Julian-Dicken · Jan 30, 2016 at 05:17 PM 0
Share

softrare

do i need the rigidbody on both objects ?

avatar image Julian-Dicken · Jan 30, 2016 at 05:27 PM 0
Share

Finally it worked ... if you have the same problem try : void OnCollisionenter (Collision other)

avatar image softrare Julian-Dicken · Feb 02, 2016 at 10:48 AM 0
Share

Glad it worked ;) I converted your answer to a comment if you don't $$anonymous$$d.

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

55 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 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 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

i have a model with capsule collider on it and when i shoot it want to dead but it not working 0 Answers

Get Random transform point inside collider 0 Answers

Instantiate is not working in unity 5.6.4f1 0 Answers

Changing depth of a SphereCollider without changing its size 2 Answers

Collider not turning into trigger when painted to a scene 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