Hi! In my atb battle system, I'm trying to create a special effect upon casting animation (using prefab and casting game event), but I want the prefab to be destroyed once the casting is completed or the casting got cancelled. Is there any way I can somehow access the prefab spawned in the cast event at the cast cancel event and destroy it, and also at the ability battle event to destroy the prefab? Or is there a solution for this?

Thanks!
  • edited February 2019
    You can create a game event and attach it to the prefab that deletes itself after x seconds.

    Alternatively if it's a skill you can select the starting node of the battle event and choose "remove prefabs" or something, it automatically deletes prefabs after the event ends (not always ideal)
    Post edited by Wrofir on
    Miuratale : coming 2024
    Miuratale
  • edited February 2019
    The prefabs spawned by one event aren't available in the other events (e.g. the cast cancel event), so you'd have to find them, e.g. via name/tag or by mounting them on a child object of the combatant.

    An alternative solution would be storing them in Global Objects, e.g. using a Change Found Objects node.
    Post edited by gamingislove on
    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!
  • edited February 2019
    Thanks for all the helpful comments!

    I tried the Global Objects method but have no idea how to retrieve the object from another event. Any hint? This is what I did so far.

    Under Spawn Prefab, Add Found Objects, input some name (value type: value, change type: add), check use Global Objects
    Post edited by Salgian on
  • I used Destroy Object node and it worked. Thanks again! Now it's solved.
  • Glad you've got it to work :)

    Small extension on the global objects - you can store any game object in a global objects list, which are identified by the key you're using. You can reuse the stored objects by just using the global objects with the same key, e.g. in different events.
    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!
Sign In or Register to comment.