Search Unity

Question How do I change the MultiplePositionBinder at runtime

Discussion in 'Visual Effect Graph' started by Torsilver, Jun 15, 2021.

  1. Torsilver

    Torsilver

    Joined:
    Nov 8, 2018
    Posts:
    4
    I made a VFX based on the Lightning effect in the example

    I want the path points of lightning to change while it's running

    Is there any way to change the contents of the MultiplePositionBinder using C# scripts?

    Or can I recreate the effect and give it a different MultiplePositionBinder?
     
  2. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    That requires your own solution to the best of my knowledge, but if you only need their positions to move instead of change the amount of them you have number of far quicker solutions at hand. Correct me if this isn't applicable.

    If you need precise control:

    You could animate the positions of the objects you are tracking for smooth motion.
    Or set their transform positions from code if you want them to snap around, say lightining striking slightly differently, when you call the event for your effect change their transforms from code that look nice.(ensure they have no colliders or if they do that they have rigidbodies so you dont incur a constant physics update cost from that).

    And most easily of all if precision isn't what you need but randomness, you need to learn how to use and abuse the stacks, everything happens in order in the graphs. You can first set the shape in initialize then add the position to them, this is how you easily rotate objects etc also without any complex math at all. (or old/target positions if you need a storable future point they dont spawn in then use Get Attribute for your update to make them behave to those points)
     
    Torsilver likes this.
  3. Torsilver

    Torsilver

    Joined:
    Nov 8, 2018
    Posts:
    4
    Thank you very much for your answer.

    So my requirement is that I want a bunch of particles to represent what the path looks like.

    Maybe I have ten paths. Every time I pick a path. I'll have a special effect to show you what the path looks like. Particles travel from the beginning to the end.

    Parts of the path can be moved. Let's say you get on a boat through a small dock. Then from the boat to another dock. The position of the ship is always moving.

    Can VFX achieve this effect? Or do I have to think of something else?