So I'm trying to use X Weapon Trail's particle effect on sword swings.
I've attached it as a prefab to weapons, which is fine, but since it runs all the time, I'm leaving the script disabled on the prefab, and trying to re-enable it through an attack event and then disable it after the attack is done.
However, nothing's happening.
Any idea what's wrong?
1) disabled script on weapon prefab
2) showing that the script is still disabled when in battle
3) tried with and without the child object, tried going the whole path down to it, tried writing just the child object which is X-WeaponTrail, tried all components
4)
help? :>
public class XWeaponTrail : MonoBehaviour
There's bound to be some mistake in path that long and it will be hard to debug.
Alternatively you could put some helper code on player object and use script to do that. Then you could use SendMessage node and send message to user gameobject.
Something like
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CombatantHelper : MonoBehaviour
{
public void ShowWeaponTrail()
{
GetComponentInChildren<XWeaponTrail>().enabled = true;
}
public void HideWeaponTrail()
{
GetComponentInChildren<XWeaponTrail>().enabled = false;
}
}
So I was able to enable it via the event with all components and XWeaponTrail no spaces. Thanks for that tip!! However, when I disable it at the end of the slash, it disables the entire object holding the script, rather than just the script. So then the event can't find the disabled object/script during the next hit. Any ideas?
trying to disable it after attack is over
after attack for some reason it disables the object instead of the script component
when the script is enabled during attack
Turn off "All components"
Unless Weapon Trial is set to a bone>child in which case you can disable all, because bones have no components by default.
Usually this shouldn't disable the game object itself - could it be that the component does that in it's OnDisable function?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!