Hello,
I want to enable/disable some components like trail Renderer during weapon attack battle event. Is it possible to target currently equipped weapon/armor gameobject and store it in selected data?
I tried this approach, it did not work. And after taking a peek at source code I don't thinks it's supposed to?
I can probably modify Select Equipment code to return game object but I wanted to see if there is a clean built in way to do this.
If you just want a trail renderer to be visible only during a swing, you could just use an Enable Component step.
The Component Name just needs to be the particle effect component on the weapon object.
Then make sure the path to the child object is correct.
Note that this means your weapon prefab objects will have to use the same name for the same event to work.
But if you just store them in different folders in the Project window it should be simple to keep them organized.
I could probably also access the Equipment viewers on the Combatant to write custom event node, but with a quick scan I was not able to find where they are stored, Equipment viewer seems to be independent from Combatant and queries it to get data.
https://unity3d.com/learn/tutorials/topics/animation/animation-curves-and-events?playlist=17099
That way the issue of references becomes much simpler.
Simply have an event at the beginning of a swing to disable the necessary components and then another at the end to turn it off.
You may also want to have a redundant turnoff event in your Idle animation just in case the attack animation is cancelled somehow.
But with trailRenderer this means the weapon might get stuck with nasty effect.