Search Unity

change color of collided part of a line

Discussion in 'Shaders' started by MPForte, May 15, 2019.

  1. MPForte

    MPForte

    Joined:
    Aug 28, 2018
    Posts:
    4
    Hello!!

    I would like to be able to do something similar:



    I am drawing a line with the mouse.
    I'd like that only the segment of the line that collides changes colour. I'd prefer to avoid to create different lines to solve this issue but I have no experience with shaders. May someone help me?


    Ps. Already tried:
    - The classical
    "line.startColor = Color.green;
    line.endColor = Color.green;"
    changes the colour of the entire line when the line collides with the cube, while I would like to change only the colour of the segment that is colliding.
    - Also changing shader does not work since the new shader is applied to the entire line as well.