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.
Any advice or pointers would be appreciated!
Comments
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.