Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
4
Question by aaron95j · Mar 04, 2015 at 04:09 PM · c#unity 5physics

Unity 5 workaround for concave colliders

As excited as I am to try out Unity 5, I can't.

My game is set in space and I have some detailed meshes as the ships. These meshes cannot practically be split up into convex meshes, the model is just too large with too much detail.

I am thinking about a workaround but I beleive my limited knowledge is getting in the way. Under the assumption this method can be made to work it is a fairly decent and simple solution without any external assets etc.

Can this work?

Firstly, the model meshes need to have a parent which is a child of the Prefab. This is so that I can attatch a script to their rigidbody Object, that is still a child of the ship. This rigidbody in use for the meshes must be set as kinematic due to the Unity 5 update. I have applied a second rigidbody to the Prefab (parent Obj). The Prefabs rigidbody can utilise the physics and the models rigidbody allows concave collisions. I am creating a basic script, which I need help with, that will pass collisions on the model rigidbody to the Prefabs rigidbody, allowing the collisions to effect the ship.

The script is applied to the model kinematic rigidbody, on all objects needing concave colliders.

Heres what I have so far..

 using UnityEngine;
 using System.Collections;
 
 public class ScriptPassCollision : MonoBehaviour {
 
     void OnCollisionEnter(Collision collision) {
         float mass = collision.rigidbody.mass;
         transform.parent.GetComponent<Rigidbody>().AddForceAtPosition(Vector3.Scale (collision.relativeVelocity,new Vector3(mass,mass,mass)),collision.rigidbody.position);
         
     }
 }
 

This seems to be working to a degree..

The effect seems way too much, is my math wrong? the ship rotates, but stops again soon after? very confused here and may have external influence.. and lastly the ship doesn't move as i would expect add force to do?

Feel free to leave suggestions in rewriting the idea altogether.. I've stayed up too late :)

Thankyou,

-Aaron

Comment
Add comment · Show 4
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 tanoshimi · Mar 04, 2015 at 07:26 PM 0
Share

"This rigidbody in use for the meshes must be set as kinematic due to the Unity 5 update." --> can you explain further?

avatar image aaron95j · Mar 05, 2015 at 05:32 AM 0
Share

error since upgrading to 5: Non-convex $$anonymous$$eshColliders with non-kinematic Rigidbodies are no longer supported in Unity 5.0

The error points to every concave $$anonymous$$eshCollider in the scene

avatar image aaron95j · Mar 14, 2015 at 10:13 PM 0
Share

It used to work, just not between two concave colliders. You could have, for example, a complex house with a mesh collider as concave and the player and other objects inside would collide with it as long as those objects are convex.

As my unity editor is now I simply cannot have a concave mesh collider with a rigidbody at all.

Eric, is 5.0f4 a $$anonymous$$or update since 5 became available or is that what was released? Not with my computer at the moment. Also what you're saying is also correct for me in terms of the is trigger box.

-Aaron

avatar image Tiberius1701 · Apr 22, 2015 at 09:57 AM 0
Share

I can attest to the fact that non-convex mesh colliders with Rigidbodies not set to "Is $$anonymous$$inematic" worked fine and registered collisions in 4.6, and not in 5.0 From what I understand, it was a Physx edict. We are in a similar world of hurt, trying to chose the best solution to this huge problem.

3 Replies

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

Answer by stanzy · Feb 23, 2017 at 08:08 AM

You could use this script as a workaround:

http://productivity-boost.com/DownloadNonConvexMeshCollider.html

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 aaronfranke · Sep 10, 2017 at 09:52 PM 0
Share

Note: The example scene needs $$anonymous$$or tweaking to get working in the latest version of Unity. But the script seems to work fine.

avatar image
0

Answer by Eric5h5 · Mar 04, 2015 at 07:47 PM

There are no issues with using concave colliders in Unity 5. Concave triggers are another matter, but you don't seem to be using those.

Comment
Add comment · Show 6 · 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 aaron95j · Mar 05, 2015 at 05:31 AM 0
Share

Error: Non-convex $$anonymous$$eshColliders with non-kinematic Rigidbodies are no longer supported in Unity 5.0

I need physics.. can't use kinematic rigidbodies.

I don't even use triggers on the $$anonymous$$eshes the error is pointing to

avatar image aaron95j · Mar 14, 2015 at 11:26 AM 0
Share

I open a new project. Create a blender model, simple cube with an indent. Load cube into scene. add rigidbody (all settings default) add $$anonymous$$eshCollider (all settings default) Error: Non-convex $$anonymous$$eshColliders with non-kinematic Rigidbodies are no longer supported in Unity 5.0

avatar image Eric5h5 · Mar 14, 2015 at 03:59 PM 0
Share

Nope, so such error here (5.0f4). What doesn't work is non-convex colliders with triggers, but you're prevented from selecting that anyway (Is Trigger is greyed out unless Convex is checked).

avatar image tanoshimi · Mar 14, 2015 at 05:22 PM 0
Share

Well, according to http://docs.unity3d.com/$$anonymous$$anual/class-$$anonymous$$eshCollider.html, "Non-convex $$anonymous$$esh Colliders are only supported on GameObjects without a rigidbody. If you want to use a $$anonymous$$esh Collider on a rigidbody, it needs to be marked as Convex." - it's not mentioned that this is a change in Unity 5 but, AFAI$$anonymous$$, concave mesh colliders have never registered collisions with other mesh colliders anyway, so the only change is that Unity now prevents you from even getting into the situation of wondering why collisions with your rigidbody concave mesh aren't being registered, because it won't let you create one in the first place...

avatar image aaron95j · Mar 14, 2015 at 10:15 PM 0
Share

Accidentally added comment to original question. See that please. Last time I'm replying here on my half dead phone sorry.

Show more comments
avatar image
0

Answer by Cephalobyte · Jun 03, 2021 at 07:58 PM

Hey, I know I'm a century late, but I think I have your answer. Right now, you're applying a force every single frame the Rigidbody is inside the collider. You either want to multiply the velocity vector by Time.deltaTime or add a third parameter at the end of Rigidbody.AddForceAtPosition() which is ForceMode.Impulse So the correct formula would either be

 transform.parent.GetComponent<Rigidbody>().AddForceAtPosition(Vector3.Scale(collision.relativeVelocity,new Vector3(mass,mass,mass))*Time.deltaTime,collision.rigidbody.position);

or

 transform.parent.GetComponent<Rigidbody>().AddForceAtPosition(Vector3.Scale(collision.relativeVelocity,new Vector3(mass,mass,mass)),collision.rigidbody.position, ForceMode.Impulse);
Comment
Add comment · 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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I make my character controller jump when I use this code? 0 Answers

Delaying Physics Calculations (Friction) 1 Answer

Crossing Soccer ball system Help 0 Answers

How do I make car wheels spin and slow down when the car is stopped 0 Answers

Unity 3D - Rotating an object in relation to its velocity 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