Search Unity

Float drive by a blendshape

Discussion in 'General Discussion' started by alexgabrielrochabrandao, Mar 31, 2022.

  1. alexgabrielrochabrandao

    alexgabrielrochabrandao

    Joined:
    Mar 23, 2022
    Posts:
    2
    Hi, I did want to know if theres any way to drive a float from a mateiral with the value of a blendshape.
    I tried something, but it's not working. :(

    Here's a simple script a create:
    Captura de tela 2022-03-31 043722.png
    I did want to set the value of the float("change") to the same value of the blendshape, but it's not working at all.


    Captura de tela 2022-03-31 043842.png
    Here's the inspector of the material.
    As you can see, right below on the "Exposed Properties" there's a slider, that's the float Change that I want to change along with the blendshape, but when I slide the frist blendshape nothing happens.

    Captura de tela 2022-03-31 044237.png
    Here's the shader graph, pretty simple, just a Lerp node, 2 different color and a float to change between the both colors.
    (sorry about any english mistake)
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,157
    Unless I'm misremembering, the Name field in Shader Graph is the name that shows up in the inspector, but not the name of the variable itself. What you want to access is the name in the Reference field instead. I suggest changing that to "_change" to follow standard shader naming conventions and then trying to access that instead.
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    That is correct, and in ops's case the shader name is Vector1_c8acdc01...

    I'd recommend to rename it into something else.

    Additionally scripts (used to) complain when you attempt to alter a non-existing property.
     
  4. alexgabrielrochabrandao

    alexgabrielrochabrandao

    Joined:
    Mar 23, 2022
    Posts:
    2
    Thank you for your reply. That solved my problem.
    Helped me so much, thank you so much. :)