1. Welcome to VRCat! Please note that this message board is not related to VRChat in any official manner. It is run entirely by the community, and moderated by the community. Any content present has not been reviewed by VRChat moderators or staff. Your use of these forums implies understanding of this message. Thanks!
    Dismiss Notice

Avatars How to play an animation on particle death.

Discussion in 'Tutorials and Tools' started by RetroGEO, Feb 11, 2019.

  1. RetroGEO

    RetroGEO New Member

    Feb 26, 2018
    Likes Received:
    View attachment 1679
    example video with sound:

    copy of readme:
    How to Use

    Move the "PulseAnimator" object so that the flashing particle collides with the "On" cube.
    This will trigger the animation, enabling the cube with a sound.
    To reset the system for the next use and disable the cube, Toggle the "Reset" animator on the "Reset" GameObject.
    This animator should turn itself off after the reset is complete.
    For use, both the flashing particle system and the collider that kills it must be jointed to the avatar where you need them. (or IKed: )
    The actual system from "Reset" down can technically be anywhere.

    So, how's this working anyway?

    I'm abusing 2 things:
    Stop-action on particle systems.
    Mechanim animator resets.

    Basically, 2017 particles now have a feature that allows you to perform an action when the last particle in the system dies. In this case, it disables the object the particle is on.
    If we use an animator to keep the object with the particle on it enabled then it will disable from stop-action and immediately enable again.
    Now, animators.
    I went over this in my state-machine cycler video:
    Essentially, turning the object an animator is a part of to disabled and enabled again while the animator is still on will set its state to "Entry" which resets the animator from the beginning.
    In this case, I'm using a stop-action triggered or "non-linear" animator to cause the animation to only play if the object is disabled and enabled again.

    Here is exactly what happens in this system:

    The "OnLogic" object immediately enters its suspend state, disabling its animator.
    The reset, which is on by default, forces the animator on the "OnLogic" object to move passed suspend into its third state then turns itself off.
    This disables the cube.
    The "OnLogic" particle being emitted by the "EnableSample" emitter and dying immediately causes the "OnLogic" object to rapidly be disabled and enabled again.
    This resets its animator to entry.
    The "OnLogic" animator enters its first state.
    This enables the cube.
    The "OnLogic" animator enters its 2nd state.
    This disables its animator, locking the state.
    Since the reset animator is off, the "OnLogic" animator will not move passed it's suspend, effectively toggling the object.
    The reset animator animates the "OnLogic" animator which forces it passed the suspend into the 3rd state.
    This disables the cube, resetting the system.

    Frankly, it's a lot to take in.
    I don't expect most of you to understand it to be honest and that's ok.
    This is here for the people that think they can and have the drive to learn something new.
    Once you figure out how it's all happening there are a ton of possibilities now available to you.

    I've spent a very long time developing this method, this is just the base logic boiled down to get you started.
    There are plenty very complex systems I've already made with this logic as a base.

    Feel free to contact me with questions or suggestions on Discord: Rero#9097