Search Unity

How to add field realtime for realize multi person interaction with C# ?

Discussion in 'Visual Effect Graph' started by duxttyiyi, Jul 28, 2021.

  1. duxttyiyi

    duxttyiyi

    Joined:
    Aug 28, 2017
    Posts:
    9
    i want the vfx to interaction with multi people and i make many field in different postion on floor
    but the vfx is not support c# to add a field realtime!
    mayabe i dont find it !

    so i put 15 field into it but itis not enough. 80 or more needed!
    QQ图片20210728183135.png

    this is all make by hand and not Intellectualization

    i want to do this in c# ,where i can find the api?
     
  2. duxttyiyi

    duxttyiyi

    Joined:
    Aug 28, 2017
    Posts:
    9
    i found the "New VFX.vfx" file can be edit as txt
    maybe itis easy to add some lines.:):D
     
  3. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Sorry, but you can't expect help if no one understands you.
    It's not possible to see anything in this attached image (tiny, zoomed out), it's just horror of blocks connections.
    From your english description I could only guess you want to create VFX graph from code.

    If you want to create VFX graphs at runtime, then I think this is not possible as it must be compiled first.
     
  4. duxttyiyi

    duxttyiyi

    Joined:
    Aug 28, 2017
    Posts:
    9
    thanks for your reply

    I mean, there are many fields created manually. Now I want to create 80 fields in batches. Is there such a script command, which automatically links some blocks in batches, which are all operated in this editor
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    I don't know, this is visual tool and I guess there is no official API to do such things. Possibly, as you mentioned you could make script to generate some content in asset file, but this is tricky and hard to say if it works at all.

    You are talking about "fields", but what I see is15 blocks, so I guess you need blocks - why would you even need so many of them? I can't think even about single scenario where I need more than 5 of them in Update.
    From my perspective your graph is just bad designed and you should consider rework.
     
  6. duxttyiyi

    duxttyiyi

    Joined:
    Aug 28, 2017
    Posts:
    9
    At present, the game I designed is to collect a lot of people on the ground with radar eyes, and then everyone has a field to simply attract the surrounding particles. Maybe my production method is wrong, but the only way I know to increase interaction at present is to add this blocks and then use position information to control their position range.
    Can you give me another idea
     
  7. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Sorry, It is really hard for me to imagine how this game looks like, but by just guessing, can't you divide your game into chunks or something like this? Or maybe you can calculate somehow culumated forces for all particles and set them once. If you need to calculate gravity force between each other attractor, then maybe you could set them in better or faster way like array of points, some point cache, buffer or texture (each pixel = attractor position).
    As I said it is hard to help without enough information, plus I am definitely not expert.
     
  8. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @duxttyiyi ,

    I agree with @Qriva , while it's a bit hard visualizing what the end goal is, creating 80+ blocks is probably not the best way to accomplish it.

    I agree with this, you can perhaps create a texture on the fly based on all of your agents positions and represent via color the velocity or position a particle should adopt when sampled at a certain position. Then you remap the min/max XY position of your particles to UV 0-1 coordinates so you can accurately sample where a particle needs to move using a SampleTexture2D operator. Here is a very bad and inaccurate mockup:
     

    Attached Files:

  9. ThomasVFX

    ThomasVFX

    Joined:
    Jan 14, 2016
    Posts:
    45
    I agree with @VladVNeykov , basically adding up more blocks for what you want to achieve is the absolute naive implementation that could work for a bunch of targets, but doesn't scale at all for a number like 80's.

    You can indeed get away by filling in first a common data structure (pretty much similar to the one shown by vlad, or even go 3d if you have multiple target elevation concerns). Filling in this buffer helps VFX process it only once to perform what you want to achieve. This way, the performance cost of reading and applying forces is always the same, only the write in the buffer matters (this way you can perform optimizations such as culling effctors out or your radar eyes or even move the buffer area to something relevant to your simulation (for example processing only what's visible by the camera).

    If you want to fill in such buffer, you can take a look at the Custom Render Texture API , as it will provide useful to clear the buffer every frame, and blit information for your targets.