What's the most efficient way to call a schematic when an equipment is equipped or unequipped? I have some scripted functions that I'd like to call via schematic when an item is equipped or unequipped.

For context, I have an equipmentmanager component in which I've created categories and added to an array for each category all of my gameobjects nested in the various bones of my character. Each category has its own number slider and number field, so I can type in whatever object I want to display. Helmet 1 would display whatever the first helmet is, etc. This is an alternative to enabling/disabling child object prefabs, since I have hundreds and the way they're nested requires me typing out huge paths.

The equipmentmanager component also has a function that can be called, and requires specifying the category string and selection int ("Helmet", 2, for example, would display whatever gameobject is in the Helmet array's slot 2). I've created an armor equipment object and added the custom variables 'category,' 'selection,' and 'colorpreset.' Colorpreset is for a different function wherein I can apply colorshader color presets to a selected object. When my schematic is called, it takes those local variables, calls the equipment manager function and specifies the category and selection (Helmet 2), and then calls my equipmentshader and specifies the preset to use.

The schematic works, but I'd like to find a way to trigger it specifically when an item is equipped/unequipped.

I got some help from the wonderful folks on discord, and currently have a tick machine going that successfully runs the schematic--albeit constantly. Tomorrow I'll look into calling the schematic when the equipment menu closes, but my only concern is that with my current equipment variable setup, I'd overwrite the local variables if I equipped multiple items before closing, since the variables would constantly update as gear's equipped. I could make a set of three variables with a related schematic unique to each equipment slot. But then I'd probably need to create a custom script to pull those variables from the combatant, then feed them through my functions. Doable, but not as efficient as I'd like.

If there are any other more efficient ways I'd be happy to hear some ideas.
  • edited April 2023
    Equipment actually has schematic settings for that. You can find them in the equipment's Level Settings, where you can set up schematics that'll be used when initializing, equipping and unequipping the equipment.
    The equipment itself is available as local selected data via the data key action in the schematic. The combatant equipping or unequipping will be the Machine Object and Starting Object of the schematic - for init schematic it's the player.
    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 April 2023
    Thank you, GiL! I was only able to test for a few minutes before heading to work and will test more after. I was able to call the schematic, however the default variable values are now being passed instead of the equipment's custom variable values.

    I checked my player combatant's variable object at runtime and the custom variables are still being set; the schematic just isn't pulling them anymore. I know I'm failing to adapt the schematic to being called via the level settings' init and equip--any tips on how I should adjust?

    I'll doublecheck to ensure the proper variable source is being targeted and if not set it to Machine Object. And for init I'll make a duplicate schematict that targets player instead. I hastily tried to use selected data with the custom schematic's key, but failed to get it to work.

    Thank you for your time and patience.
    Post edited by VictryForWA on
  • The equipment's variables are available via Selected Data variable origin, using the local selected data via data key action.
    Machine Object/Starting Object will give you access to the combatant equipping/unequipping it, so also to it's variables.
    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!
  • Perfect, thank you! I had everything set up correctly, except for having the start node initializing and setting the variables I was using--my function nodes were pulling those variables rather than the equipment's variables.

    Thanks again, works great!
  • Small addition - next update will add default equip/unequip schematics for all equipment to the inventory settings. So, if all equipment has the same setup, you can make your life a bit easier that way :)
    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!
  • Fantastic! That'll definitely come in handy. Looking forward to it, as well as the new features you've shared on twitter!
Sign In or Register to comment.