• 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
Question by spiceboy9994 · Aug 20, 2013 at 03:24 PM · mesh verticesvertex colormesh color

Vertex Material add Burn Mark on Hit

Hi:

I am very new on the the UVs and meshes Vertices and colors topic. So I need to ac$$anonymous$$eve the following. I have a scene with a Single Model. The model has a Vertex Colored Shader Material with a single texture over it. I have a code that allows you to place a flame sprite over the model where you actually place the flame. I have the code that allows the player to drag the flame over the model and adds burn physics to the flame and the model, I have also placed some nice burning sound. However, Im not sure about how to ac$$anonymous$$eve the following: burn the material where the flame $$anonymous$$t occurred, by changing the vertex colors of the mesh only on the spot where the flame was burning. I know that I have to change the color Array of the mesh, but I dont know how to get the specific "polygons" or "area" where the $$anonymous$$t actually took place. Does anyone know a resource that I can refer to learn how to do t$$anonymous$$s?

Thanks a lot.

Comment

People who like this

0 Show 5
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 spiceboy9994 · Aug 20, 2013 at 03:36 PM 0
Share

Another important thing is that needs to be an "Area burn"... not just changing the color of specific pixel point. Thanks a lot again

avatar image $$anonymous$$ · Aug 20, 2013 at 03:51 PM 0
Share

If your model isn't a SkinnedMesh you can try to apply a decal. If you download the free asset Bootcamp from the store there is a simple decal system, that build a decal mesh on the fly based on the collision of the object hit and apply a decal texture. But if your model is a SkinnedMesh you can't do that as the decal would need to be rigged within the bone hierarchy of the mesh.

Alternatively to paint the vertcies you can do with a raycast, fire a a raycast toward the mesh from the flame, and from the raycast try to find the nearest vertices of the hit point, then build an array from what can be found and color them.

Check this for further info on this second method:

http://answers.unity3d.com/questions/43415/finding-the-polygonface-youre-currently-looking-at.html

avatar image robertbu · Aug 21, 2013 at 04:39 AM 0
Share

You do a Physics.Raycast() or a Collider.Raycast() to the point of the flame. The RaycastHit structure returns a RaycastHit.triangleindex. This index allows you to find the three vertices of the triangle hit by the raycast. There are sample source on the reference page for finding vertices from the RaycastHit.triangleindex. Since there is a one-to-one correspondence between vertices and vertex colors, the same logic finds the the colors in the color array:

     var c0 = colors[triangles[hit.triangleIndex * 3 + 0]];
     var c1 = colors[triangles[hit.triangleIndex * 3 + 1]];    
     var c2 = colors[triangles[hit.triangleIndex * 3 + 2]];   
avatar image spiceboy9994 robertbu · Aug 29, 2013 at 08:51 PM 0
Share

This answer implies that the mesh are components of the same game object right?, thanks so much, but it is not the case.

avatar image spiceboy9994 · Aug 29, 2013 at 08:51 PM 0
Share

I have been struggling with this solution, but heres some important factor: the mesh and the colliders are different game objects. I have a gameobject that has the whole mesh of the model, and different colliders for each limb of my model (since it is a ragdoll). I have tried the second method, but the burning is not precise.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

Graphics.DrawMesh - cannot set mesh color 0 Answers

change color of the selected triangles inside human chest 1 Answer

Mesh.colors doesn't work even though colors are passed correctly to the array 1 Answer

Mesh.colors returns zero 1 Answer

How I can get InteractiveCloth vertices and apply to MeshFilter 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