Playmaker Has item with definition action request

snicker

Member
I would like to use FSM object variables to set the item definition the Has Item with definition actions are checking. this would really help cut down on the spaghetti states

I'm trying to set the itemdefintion as a variable at the end state to check if the itemdefinition is the same as it was the end of the previous loop
 
Last edited:
I thought you could just hook a variable to the ItemDEfinition field but I guess I was wrong.
I've added a new ItemDefinitionVariable field. You can use that instead of the ItemDefinition field which is a constant. Now the code first check the variable and then the constant. Please find the code attached. If it works let me know and I'll update the integration package by adding this option to all the scripts that could benefit from it
 

Attachments

There should be a new PlayMaker integration version with the same improvements made for other actions
 
I am trying to get the float named +Health from the itemdefinition attribute and save it as a playmaker variable named +Health, it is returning as 0, is this action set up correctly?
get health attribute.png
 
Sorry I forgot about the itemdefinition variable in the GetSet action. Please find the updated script attached.

Your attribute is named "+Health"? I would highly advise against using names which would not be valid variable names so if possible use only those characters for attribute names: "a-zA-Z0-9_".

There are a few reasons this action would fail.
1) If the inventory does not find an item with that item definition in the item collection provided.
2) If the Attribute name does not match anything
3) If the Attribute type (in this case Float) does not match the attribute name

In all those cases the Fail Event would trigger.

I took the time to add another option that lets you get the attribute on the ItemDefinition instead of on the Item. This way you can get attribute values without even needing the item to be in the inventory. Note that you cannot set the value on ItemDefinitions because they are scriptable objects which should never change at runtime (otherwise you'll get a lot of unwanted persisting data in the editor, and not in a build version which is a very bad idea)

I hope that helps you solve your issue
 

Attachments

The new script works for using the itemDefinition as a variable but still returns 0.

I changed the + to bonus and am using the new action.

The character has the item in the inventory in equipment slot collection. I'm using has item with category/definition to determine what items are in the inventory in previous states, I only want to use this action to get UIS attributes and save them as PM variables. The float is still returning as 0 whether I enable Get Value On Definition or Get Value on Default Item(the values are currently the same). The attribute name matches in the action and UIS editor, I made sure there isn't a space at the end of the word or anything.


The Playmaker float bonusHealth is 0 until it gets the UIS attribute then adds/subtracts UCC attributes in other states.
I'm not using success/fail events or setting any UIS values, just getting a few values from UIS to set the FSM variables to use in the next state and again to remove the stats/mesh from the previous item. The state before this one determines what item definition it is, then this gets the stats from that itemdefinition's attributes, then the next state apply the stats using the UCC PM actions.

If target game object is set to Use Owner instead of specify GO -> none, the Value is changed to none at runtime when the action runs, this FSM is on the same GO as all the inventory.
I tried putting this action on an empty GameObject fsm and cant seem to return anything but 0 with various settings.

I also want to get a gameobject attribute from UIS and save it as a Playmaker variable for the visual armor pieces, the get set attribute object action doesn't let me set an FSM game object variable.
peasantboots.png
 
Last edited:
You are right there was a bug where it wasn't using the variable, instead it was replacing the variable by a value.

I added GameObject to the get set file. And I made it such that you don't need an inventory if you are getting the attribute from the definition or the default item. Please find it below

I hope that solve all your issues.
 

Attachments

Thanks, it works now. I was able to set up my equipment logic with playmaker!

Get Set Item Attribute Value Material would be really handy too, as I move onto setting up the skinned mesh equipment pieces
 
You should be able to use GetSet Object for that since it works for all assets. Of course you'll need to make your attribute an (Unity) Object attribute for that to work
 
That doesn't work for me because then the FSM variable has to return an object.material instead of a Material, and i cant use it as a Material with the regular PM Material actions.
There's a conversion action for Material to Object.material but not the other way around and nothing on ecosystem for that.
Get property won't return any material variable from object.material so I still need to get a Material variable from UIS.
 
It seems odd to me that there is no way to convert Object to Material, You should make a feature request to the PlayMaker devs.
Looking at their source code the only asset type they have is Material and Texture. Meaning that if there isn't a way to convert Object to a specific type, there is no way for you to use any of the other asset types in play maker, such as AudioClip, ScriptableObjects, etc... That seems extremely limited.

Please find attached the latest script it contains ALL the FSM variable types that match base types.
 

Attachments

Thank you this is just what I needed! and more!
Playmaker is dependent on a public API, I generally just use the object variables for storing components, and for UIS, itemdefinitions/categories
 
Hello, I am having another bug with this action, the Has Item With Category/Definition does not seem to work unless set to Use Owner, it returns neither success nor failure when the target object with inventory being checked is a variable and stops the fsm.
 
Can you double check that your variable gameobject indeed has an Inventory component?
We use this to get the inventory on the gameobject:
Code:
public override void OnEnter()
{
    var currentGameObject = Fsm.GetOwnerDefaultTarget(m_TargetGameObject);
    if (currentGameObject != m_PrevGameObject) {
        m_Inventory = currentGameObject.GetComponent<Inventory>();
        m_PrevGameObject = currentGameObject;
    }
    
    ...

I've changed the code such that the task should fail and you should get a warning when the inventory is null. That update should be ready later this week.
 
I have 8 of these equipment FSMS, they were all on my character so Use Owner was checked, to clean up the components on my player gameobject, I tried moving some less essential ones around and just using a reference to the player object instead, but the FSM gets stuck in this state
 

Attachments

  • PlaymakerUIS.png
    PlaymakerUIS.png
    98.8 KB · Views: 5
Try downloading the latest Playmaker integration it should prevent things from being locked in a state.
That being said it would only happen when the Character is null or the Inventory is null. Double check that it is not the case
 
I am trying to use Get Set Item Value Object to return a Mesh but it always returns null, does this need a custom action too?
 
Back
Top