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

Question Calculate distance between vector and particle in WS

Discussion in 'Visual Effect Graph' started by Ofenkatze, May 10, 2023.

  1. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
    Hello everyone!

    I have a graph that has to be in local space for reasons. I'm calculating the distance between the player (represented here by a sphere) and any given particle in world space and send the result to a color lerp to light up the particle closest to the player:
    upload_2023-5-10_16-22-55.jpeg

    upload_2023-5-10_16-26-25.jpeg

    upload_2023-5-10_16-29-42.jpeg

    That's working fine as long as the graph sits at 0/0/0. Since the distance is calculated in world space, expected behaviour would be for the highlight to disappear as soon as I move the VFX graph out of range. But the highlight stays with the graph when moved, as if calculation would actually use local coordinates (also see attached gif).
    upload_2023-5-10_16-30-13.jpeg

    What am I missing here?
     

    Attached Files:

  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    306
    Hello. I guess your player position is already in world space, so converting it from local to world space seems indeed wrong.
     
    Qriva likes this.
  3. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
    omg you're right! I've been staring at this graph for an hour and did not catch that bug, thank you so much!!! <3