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 Avatar Toggleable Objects

Discussion in 'Tutorials and Tools' started by ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ, Sep 30, 2018.

  1. ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ

    Joined:
    Jun 17, 2018
    Messages:
    4
    Likes Received:
    7
    VRChat:
    ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ
    Rip Legacy Animations.
    Unfortunately in all newer versions of VRChat, legacy animations have been removed due to security concerns.

    The good thing is that normal animators can do everything that legacy animations could do, and way more. This isn't like removing cameras or custom controllers that were removed without giving us alternatives.

    Because of this, Inventory systems such as Snail's Inventory and Toggle Props will no longer function, however it is possible to achieve the same effect using a standard Animator and a special type of keyframe known as a Behaviour Keyframe.

    Behaviour Keyframes:
    Behaviour keyframes are a special keyframe that can be used in an animation clip. They normally require a script to create, but can be easily copied and pasted from one animation to another. They are basically future-proof seeing as they are a built-in part of Unity, that can't really be detected by VRC. These keyframes only serve one purpose, and that is to enable or disable the first component of any object under the transform.

    What can we do with these?
    Animators, when turned off, do not revert to the previous state or reset, instead they completely freeze on the last frame they where on, which can be used to turn GameObjects on or off. Unfortunately everything has it's drawbacks, similar to using legacy animations to toggle objects, if your avatar is culled out or not in view, the animator will not sync, it also will not sync to late joiners. Just remember users have to see you toggle the object.

    You must also make sure that there aren't any other parent animators affecting the animators used in your toggle system, else it will just reset back to whatever that parent animator has written in it's animations.

    How to set up the inventory system:
    Included is a Prefab for a Basic Inventory Setup that will allow you to toggle an object and two emotes for turning said object on and off.
    As well as a new editor script created by user Xiexe to generate your inventory system anywhere on your model!. just use the Xiexe-Tools-Inventory Remapper option in unity top bar.

    By default the prefab is set up to work on the root of your avatar, so if that's all you want to do then you can simply drop the prefab on to the root, place your item in the “MyObject” GameObject and finally, add the “Item ON” and “Item OFF” animation clips to the emote slots on your override controller, and that's it.

    However if you're looking to put the prefab somewhere on your armature or use multiple items, you have to correct the path to your "Inv" prefab. To do this, first duplicate the "Item ON" animation clip and rename it whatever you want. Open up the clip and scroll down to the Behaviour keyframes, there should be two properties named "ENABLE" and “DISABLE” simply hit F2 and correct the path to wherever you placed the prefab. So if you put it on your Right wrist in your hierarchy, you would change the path for the property to "Armature/Hips/Spine/Chest/Right shoulder/Right arm/Right elbow/Right wrist/Inv/Item_1/ENABLE" Do the same for the "DISABLE" property, then the "Item OFF" animation clip. If you did everything correctly you should be ready to go.

    A quick explanation from Error.mdl
    For a simple inventory system, stack two animators. One that turns an object on, one that turns an object off, and the actual object underneath that. Turn both animators off by default, then use the behaviour keyframe to turn the "on" animator on in an emote and turn on the "off" animator for any other items.
    item1_on
    item1_off
    item1
    item2_on
    ....

    Update: now includes editor script and fixes to said script.
    System Made by NepsyNeptune,Error.mdl,Weong and Xiexe
    Now includes editor script to generate your system easily anywhere on your model!, editor script created by user Xiexe.
    Download Link=
    https://github.com/Xiexe/VRCInventorySystem/releases
     
    #1 ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ, Sep 30, 2018
    Last edited by a moderator: Oct 4, 2018
  2. ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ

    Joined:
    Jun 17, 2018
    Messages:
    4
    Likes Received:
    7
    VRChat:
    ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ
    Also, if you're looking to convert your old simple legacy animations, and looping animations (blinking, idle animations, and so on), follow this video to help with that. Provides a nice explanation of how to go about doing that.


     
    Mimi likes this.
  3. ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ

    Joined:
    Jun 17, 2018
    Messages:
    4
    Likes Received:
    7
    VRChat:
    ɴᴇᴘsʏɴᴇᴘᴛᴜɴᴇ
    if you would like to use this system with gestures instead of emotes, take a look at this video!.