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 vexe · Aug 16, 2014 at 06:13 AM · collidermeshmesh collider

Use low-poly collision mesh for a high-poly model?

So I have a high-poly zombie model (from Mixamo) - I'm working on a body-sensitive damage system where if you hit the head you cause more damage, hit the feet the zombie might fall, etc. So obviously I need good collision detection for this. Using primitive colliders foreach part is just too tedious... Using a MeshCollider is very expensive. So I told my modeler to create a low-poly/decimated mesh to use for collision.

But here's the problem:

alt text

I have no idea how to align the low-poly mesh with the model... i.e. how to make the model 'wear?' his collision mesh? not to mention the character's animated so he's gonna be moving at runtime so the collision mesh should update too... (Note that the zombie's using a SkinnedMeshRenderer...)

I'm just looking for ideas here/kickstarts...

Thanks for any help!

prob.png (207.4 kB)
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 Huacanacha · Aug 17, 2014 at 09:15 AM 0
Share

I may be wrong but I think collision meshes don't animate so if you use a separate collision mesh your collisions wouldn't be in the correct place.

I'd also suggest using composite colliders as per @zharik86 answer. That's what I did for the goalkeeper for my soccer game.

avatar image vexe · Aug 17, 2014 at 10:10 AM 0
Share

Thanks for dropping by. You are correct. There's a thread in the forums that updates the mesh but it's pretty damn expensive... I ended up going for composite/compound colliders like you saw in my other collision issue video...

avatar image Huacanacha · Aug 17, 2014 at 11:03 AM 0
Share

Yep. They're a pain to set up aren't they ;)

avatar image vexe · Aug 17, 2014 at 11:16 AM 0
Share

Yes but I actually added position handles to them so I could easily position them ins$$anonymous$$d of having to manually input coordinate values which is pain. Combine that with orthographic view, and it's a bit more acceptable... $$anonymous$$aybe later on as things become clearer I could figure out a way to automate the process.

1 Reply

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

Answer by zharik86 · Aug 16, 2014 at 06:31 AM

Certainly, in my opinion, the best decision is composite colliders with unique tags: head, foot, etc. It is interesting how define you in what section of a body hit when using meshCollider? Probably only on coordinates. On your picture at you objects don't match. Check pivot point at your two models. For check simply move two your fbx on a scene to coordinates (0,0,0) and look at result. Also it is possible to check in any 3d editor. For example, in the 3D Max. Most likely at high-poly pivot to be below under feet, and in low-poly - in the middle of model.

Comment
Add comment · Show 9 · 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 vexe · Aug 16, 2014 at 06:45 AM 0
Share

Hi thanks for your answer!

  It is interesting how define you in what section of a body hit when  using meshCollider?

The thing is, I'm using Final I$$anonymous$$. It has a Hit Reaction demo which is nice. From the HitReaction script, you create hits and reference the body parts that you would like (head, arm, leg, etc) So what I did (my initial attempt) is, when the player's shoot a zombie (via raycast) I get the nearest body part to the raycast hit.point, and then apply damage to that body part... It worked pretty well. It even works (in a not-so-great way) if I just used a capsule collider for the whole zombie...

It might well be a coordinate issue yes... but even if I solve it, I still need to have the collision mesh be adjusted when the character's animating...

avatar image tanoshimi · Aug 16, 2014 at 07:16 AM 1
Share

I agree with @zharik86 - if you break apart your low-poly model into separate submeshes (for upper arm, lower arm, hand etc.) then you can parent them to the corresponding bone in the high-poly model's armature and they will stay aligned when the model is animated.

I can't see how you'd do this otherwise, short of duplicating the armature, controller, and all animations across both models.

avatar image zharik86 · Aug 16, 2014 at 09:47 AM 0
Share

@vexe When at you it will turn out to combine correctly models then it is necessary to make their animation. @tanoshimi is right, objects duplicating is necessary. For example, I did game in which on the hero it was necessary to dress the armor (a helmet, a torso, gloves, etc.). Naturally, all armor and the hero are made on one rig. But I separated finite files: separately fbx of the hero, separately fbx of a set of armors. Now main thing for object with animation: if you open it in the Inspector, has the main mesh (the hero, the zombie or something else) and a tree of simple gameObjects with the Transform component (in fact a tree of bones). Skinned$$anonymous$$eshRenderer is bound to this tree. Any animation changes tree components, and we receive a certain movement of parts of a body of the hero. If to create gameObject with the Skinned$$anonymous$$eshRenderer component and to make binding programmatically on the same bones, as at the main hero, created gameObject also will be animated (provided that rig are identical).

So, you have two models. First (high) has an animation, at second (low) the binding to identical rig shall be made in the 3D editor. Then they can be combined programmatically and further to make prefab. There is the second way (easier), two models shall be in one fbx file.

avatar image vexe · Aug 16, 2014 at 04:16 PM 0
Share

Sorry if I sound thick-headed (which I am, I have no experience with animation nor modeling techniques, I'm purely a programmer), but I don't know what you mean guy by 'object duplication' - $$anonymous$$aybe I should have mentioned that my zombie model (the high-poly) is actually split into different transforms (spine, chest, body, leg, shoulder, thigh, hips, etc). So you're saying the best way to attach colliders to these body parts?

avatar image b1gry4n · Aug 21, 2014 at 04:13 AM 2
Share

You dont use low poly colliders for skinned mesh objects. Atleast from what I know and understand it is never done this way.

I know you are against the primitive colliders...but its the best way I have found for hit detection. Attach primitive capsule colliders to the actual bones. Bones are just points in space just like any other game object.

$$anonymous$$ake a new game object, child it to a specific bone (try the head first). zero it out. add a sphere/capsule collider component. scale it correctly so it fits just outside the mesh of your character. $$anonymous$$ark as trigger.

I put my hit detection objects on their own layer

$$anonymous$$ake sure in the physics matrix that the hit detect colliders do not collide with themselves or the enemy it is on. Attach a simple script with some bools on it..

 public bool head;
 public bool leftArm;
 public bool rightArm;
 public bool leftLeg;
 public bool rightLeg;

$$anonymous$$anually check each collider youve made with the correct bool.

Whatever hits these objects (if its a ray make sure you layermask the hitdetect layer) do a check.

 if(hit.collider.getComponent<YourHitDetectScript>().head){
 ExplodeHead();
 }
 

This really isnt a tedious process. Once its set up its done. You could even set up one collider and copy/paste it to the other bones. Zero out the position/rotation. Fix the scale of it. select the correct bool for your hit detect script. Done

Show more comments

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

23 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

Related Questions

Find right mesh for collider 1 Answer

Scale collider independent of gameObject. 1 Answer

Correct position of overlapping meshes 0 Answers

Default Mesh colliders are not working 1 Answer

Adding colliders to human imported fbx - Newbie 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