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
image

2) showing that the script is still disabled when in battle
image

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
image

4)image

help? :>
  • try XWeaponTrail no spaces, or better yet select a cog icon next to trail component and click Edit Script and copy the script name from there. Should be something like
    public class XWeaponTrail : MonoBehaviour
  • Should I still have the childpath there?
  • edited June 2019
    I think it will be easier if you don't write child path and select all components.
    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;
    }
    }


    image
    Post edited by hellwalker on
  • edited July 2019
    Hmmm... I had an issue with getting the namespace the weapon trail was in.

    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
    image

    after attack for some reason it disables the object instead of the script component
    image

    when the script is enabled during attack
    image
    Post edited by PBoTG on
  • edited July 2019
    It's because it's disabling all components, including any mesh renderers and physics objects.
    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.
    Post edited by Wrofir on
    Miuratale : coming 2024
    Miuratale
  • All Components only uses components of the defined component name, so when using this option, you don't have to define the child path to the component, as it'd use all matching components on the game object and child objects.

    Usually this shouldn't disable the game object itself - could it be that the component does that in it's OnDisable function?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Got it! That's exactly what happened. It disabled it in its code. So, I commented that out for my own sanity. Thanks guys!
Sign In or Register to comment.