Forum rules - please read before posting.

Is it possible to change an actionlist parameter in custom action?

edited September 2017 in Technical Q&A
Hi forum!

What I'm trying to achieve is:

When you press an input button, the player starts holding the next item from its current inventory in its hands.

I'd want to do it in an actionlist, this way:
A Custom Action that looks what the current selected inventory-item is. If it's nothing it selects the first one, and if it's something it's selects the next one, and if it's the last one it deselects it. Then it looks at the linked Prefab of that item and stores it in the actionlist's gameobject parameter. (I'm somewhat halfway with this, I'm a slow/beginner coder. I am a bit clueless how to deal with the parameter and am not sure where to begin or if it's possible.)

Then the Character - Hold action puts that gameobject parameter in the player's hand.

Done!

I've read the tutorials on custom actions, but I'm still not sure if this is a possible/good approuch.


image

Any advice or pointers would be appreciated!

Comments

  • Yes - parameters can be modified at any time.  If you want to modify parameters in the same ActionList, you can get a reference to them within a custom Action's AssignValues override:

    override public void AssignValues (List<ActionParameter> parameters)
    {
        int parameterIDToModify = 0; // Modify the first parameter

        ActionParameter parameter = GetParameterWithID (parameters, parameterIDToModify);
        parameter.gameObject = gameObjectValue;  // The GameObject to set it to
        parameter.intValue = constantIDValue;     // The Constant ID of the GameObject to set it to (optional)
    }


    For a practical example, see the ActionParamSet code (ActionList: Set parameter).

    You'll also have to instantiate the gameobject into the scene if it's not already present, but that can be done with the Object: Add or remove Action which also accepts parameters.
  • Thanks, changing the parameter is working now, so the character can actually hold the prefabs now.

    I'm having a lot of trouble getting the action to actually cycle trough the inventory properly though. My code is a mess right now and it's costing me too much time so I'll leave this on the shelf and focus on some artwork for now. The joys of doing a 1 man project with too little time :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.