Hi. I'm trying to figure out how to get an object from inventory and add it into hand so that Final Ik would hold it. Has anyone else already done this?
If you're just looking to spawn a prefab and parent it to a child of your Player, you may be able to get by with a pair of Object: Add or remove and Object: Set parent Actions.
Things will be more a little more involved if you need to specifically access a Final IK variable or function. Scripting may be necessary, but the AC side of things should be quite simple.
Create a prefab of the scene object that represents the Inventory item when held, and assign it as the Item's Linked prefab in its list of properties.
You can then right-click on the "Linked prefab" field label to get an API reference to it, which you can copy/paste into a custom script.
For example, to spawn the linked prefab into the scene, you'd use something like:
Where "2" is replaced by the ID number of the item you wish to spawn.
How this would then be used by Final IK would be a question for Final IK's developer, but you can run custom code either through Actions (Object: Call event or Object: Send message), or by event hooks.
Event hooks are the best way to run custom code, as they can be set up to run automatically when certain AC events are triggered - for example, when an item is selected/deselected in the inventory.
Here's a sample script that uses those two events (OnInventorySelect and OnInventoryDeselect) to spawn and remove an item's prefab from the scene whenever an item is selected/deselected:
Comments
If you're just looking to spawn a prefab and parent it to a child of your Player, you may be able to get by with a pair of Object: Add or remove and Object: Set parent Actions.
Things will be more a little more involved if you need to specifically access a Final IK variable or function. Scripting may be necessary, but the AC side of things should be quite simple.
Create a prefab of the scene object that represents the Inventory item when held, and assign it as the Item's Linked prefab in its list of properties.
You can then right-click on the "Linked prefab" field label to get an API reference to it, which you can copy/paste into a custom script.
For example, to spawn the linked prefab into the scene, you'd use something like:
Where "2" is replaced by the ID number of the item you wish to spawn.
How this would then be used by Final IK would be a question for Final IK's developer, but you can run custom code either through Actions (Object: Call event or Object: Send message), or by event hooks.
Event hooks are the best way to run custom code, as they can be set up to run automatically when certain AC events are triggered - for example, when an item is selected/deselected in the inventory.
Here's a sample script that uses those two events (OnInventorySelect and OnInventoryDeselect) to spawn and remove an item's prefab from the scene whenever an item is selected/deselected:
The spawned object will also be parented to the object that the script is placed on.