Search Unity

Footsteps Based on Vertex Colors rather then Terrain Materials?

Discussion in 'Scripting' started by Bullets42, Sep 29, 2014.

  1. Bullets42

    Bullets42

    Joined:
    Jun 26, 2012
    Posts:
    13
    I am no programmer you all should know but I am doing my best to learn C#. That being said I was going to use footstep sounds that worked with textures, in other words the player steps on the texture material for grass and they hear grass footstep sound effects same would be said for gravel or rock. Now the thing is polyworld terrain doesn't use textures so I am having a hard time figuring out a new concept on how I could achieve that. Walking on different vertex colors to produce different sounds or something is this possible am I making sense?

    Link to PolyWorld

    Thanks for taking your time to help!
    -isaac
     
  2. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Isaac,

    You'll have to do some coding. Here's an idea that's just off the top of my head:

    http://forum.unity3d.com/threads/terrain-and-footsteps.131062/ is a good way to get started, except you'll be grabbing the nearby vertex color instead of the pixel.

    For terrain, you'll have to test for the vertex color the player is nearest. Then, I would probably check it's saturation value. If it's less than maybe 20, I would assume it's rock so I would play a rock sound. If it's higher than 20, then check the hue. You'll have to decide what hue range defines a surface type. For example, a hue value between 120 and 100 might be considered grass. If it's a value between 175 and 200, it might be water. You'll have to define sounds for color ranges.

    For the props, you could just set one sound/surface type as usual.

    This could be a great upgrade to PolyWorld. I won't be able to devote time to setting it up for the next version, but I will add it to the list of things to look into doing. Hope this helps!
     
    Bullets42 likes this.
  3. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Strike that. You'll get the triangle the character is standing on and sample the color from any vertex on that triangle. They're all the same.