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
1
Question by Brokenarrow · Jun 12, 2013 at 06:53 AM · collisionrigidbodyobjectsseperate

Rigid Body collision problem

Hi, I've run into a weird problem. I've asked something similar, but I feel I have now distilled the problem more clearly.

My goal is to have an object, object "A", consisting of 2 objects, called for convenience Front and Back, which have the following demands:

-Front and Back are initially attached to each other and move together by player input

-Front and Back have different colliders and are supposed to receive different collider data. (So they need individual rigidbodies)

-Front and Back are both able to collide in every way with everything in the scene, including duplicates of object A. (So Front can't be kinematic)

-Front has to be able to collide but must be unaffected by gravity. (So Joints didn't work either)

The thing is, I've tried all sorts of setups, but I can't get it to work properly. Its meant for a simple bumperkart game, where the front grill can at some point break off, but I'm absolutely dumbfounded by this particular problem. Any help would be appreciated.

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 Fattie · Oct 15, 2013 at 10:53 AM 0
Share

@Brokenarrow you must TIC$$anonymous$$ an answer, thanks. Please choose one answer and tick it, to close out the question. Only you can do so.

1 Reply

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

Answer by Fattie · Jun 12, 2013 at 07:03 AM

"My main problem is, I need to differentiate between two colliders on one object"

fortunately it couldn't be easier dude ..

let's look at the manual :)

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html

links to ..

http://docs.unity3d.com/Documentation/ScriptReference/Collision.html

what do we have here ...

http://docs.unity3d.com/Documentation/ScriptReference/Collision-contacts.html

et voila !

http://docs.unity3d.com/Documentation/ScriptReference/ContactPoint.html

alt text

 function OnCollisionEnter(cc:Collision)
     {
     Debug.Log("I got hit ... ny name is ... " + gameObject.name);
     Debug.Log("but even better, here's the specific collider on this side ... " +
             cc.contacts[0].thisCollider.name );
     }

remember only ONE object has the RIGIDBODY -- the HIGHEST LEVEL object.

put EACH OLLIDER on SEPARATE holder objects UNDER that object.

put my EXAMPLE script on the HIGHEST object (the one WITH the RIGIDBODY)

Hope it helps!!


Hey Broken - on these problems, it is REALLY MUCH EASIER if you just include an image and explain what you are trying to do. But I think I understand your problem.

I believe the likely solution to your problem is very simple:

"where the front grill can at some point break off..."

this is very common in games.

just have ONE COLLIDER for the overall car

the collider image is a CHILD of the overall car

have a collider on the bumper BUT TURN IT OFF

To make the bumper fall off:

(A) TURN ON the collider for the bumper

(B) .. explained below ...

(C) then make the bumper NOT a child of the car. in other words, on the bumper say transform.parent=null;

that's it.

What is "point B" ? It should work fine with the above, but if you can be bothered, do this.

You can see that your car needs two different colliders. So, when you include the bumper, the car is a little longer right? When you have no bumper it is shorter. So simply, set up two different colliders for the car and swap between them. Or very simply - just change the length/centerpoint of the collider on there.

(Aside -- as a matter of fact, on a simple game you can just even set the length of the collider automatically to match the bounds of the renderer.)

In general it's important to understand this principle: when you have vehicles (or any thing in the game) that breaks apart or something "comes off". You're going to have really different objects before and after. Very commonly, say someone gets blown up and is dead -- in fact you just swap to another totally different prefab or model after wards. (You make all the, say, arms, colors etc match and then swap from one to the other. the player thinks you have "altered the model" - say by the bumper falling off - but in fact you've trickily swapped to another totally different set of models. So this is precisely an example of that.

So it's that simple I hope it helps!

By the way ... "Its meant for a simple bumperkart game" ... bumper kart games are extremely complicated! Vehicle games are much harder than shooters, etc.


collide.png (90.1 kB)
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 Brokenarrow · Jun 12, 2013 at 08:27 AM 0
Share

$$anonymous$$y main problem is, I need to differentiate between two colliders on one object. If I take one collider for the entire object, when the Front gets hit, the Back registers a hit as well. But the front is supposed to protect the back from getting hit in the first place. And as only rigidbodies can actually physically collide with each other, but are affected seperately by physics, I can't find a way to keep them together. But I might reformulate my question and add a picture, to make things more clear. Thanks for the explanation!

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

OnCollisionEnter doesn't work if enemies and allies have rigidbody ? 1 Answer

Trouble with OnCollisionEnter and Exit 1 Answer

Rigidbody: how to get collisions for the current frame ? 0 Answers

Car dynamics? 0 Answers

Avoid Player bouncing when colliding with objects 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