keijiro / Smrvfx

Skinned mesh sampling with VFX Graph
The Unlicense
1.08k stars 153 forks source link

How to reference any Prefab to start VFX? #37

Closed Hiran-Nair closed 1 year ago

Hiran-Nair commented 1 year ago

Hi Keijiro, got stuck with a small problem. So apparently I have an Avatar which is working fine when tracking my body. When integrated your VFX with the Avatar it is working fine. So my problem is this:

I have a scene where every time a new user appears in front of Kinect, an avatar instantiates. I want to apply the same thing in your VFX thing but the problem is...my object gets instantiated but my VFX is not working as per the avatars that pop out. After further research in your project, I found out that the reference that is assigned to the VFX is in the Hierarchy Window and not from the Prefabs section, which was the reason why it was working properly in the Single Person Tracking...and also in the timeline section we need to refence the VFX GameObject as well. But when I gave the reference to the avatars (which are getting instantiated) in the VFX, nothing much happens, nor the VFX plays as per the bodies that are getting tracked.

Basically, I want to show multiple meshes with the VFX as per the users appearing on the screen.

PS: Attaching here is some videos for the reference;

[FIRST VIDEO] This is the one where multiple Avatars get instantiated as per user presence https://user-images.githubusercontent.com/105865232/190962179-68ee8443-6625-4396-9a90-ee1c6768074b.mp4

[SECOND VIDEO] Same thing but as problem mentioned, avatars get instantiated but no VFX gets played https://user-images.githubusercontent.com/105865232/190962272-bba5ffa3-ac69-4c21-a4ca-0c8d7eeaa45f.mp4

And here is the screenshot attached where I gave reference to this image

The lease possible solution that I've went for this is duplicating multiple avatars in Hierarchy, duplicating multiple VFX GameObjects and assigning each avatar that is duplicated in their respective duplicated VFX, and duplicating multiple Timeline GameObjects to add VFX as a reference. It works but I want to get rid of avatar as soon as user moves out of the camera rather than just staying in the middle of the scene which is visible.

If you want to see the code, I can provide you. But, can you please help me on how to achieve this Multiple Avatars with VFX?

keijiro commented 1 year ago

First of all, this question is about your personal project rather than the project here (Smrvfx). Please understand that this issue tracker is dedicated to recording issues about this specific project -- It's not a place for providing project consulting

I think what you should do is dynamically creating Property Binders when instancing character prefabs.

https://docs.unity3d.com/Packages/com.unity.visualeffectgraph@15.0/manual/PropertyBinders.html

Or you can simply deactivate character game objects when you want to hide them. Later you can reactivate when you want to re-add them to the scene.

keijiro commented 1 year ago

I'm closing this issue as answered. Please reopen it for further technical issues about the Smrvfx project.