Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Change texture of an object?

Discussion in 'General Graphics' started by imDanOush, May 27, 2016.

  1. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Hello.

    As you may know, there was a game called CrashDay, it is about crashing and destroying cars. One of the features of that game is visible when you hit your car to an other object. When you hit it, the "faces" of polygons of the car that collided with the object, get another texture, here is a photo of what I'm taking about:





    How recreating such an effect is possible?
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    You can use a shader that reads the vertex colors of the mesh to determine what texture to use for that part of the mesh.
    Then you can set the vertex colors via a script when the car was damaged.
     
  3. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Is it possible to paint vertexes via script on the OnCollision() function?