How can I attach a script to apparel that runs when it's worn?

Started by Knight, September 15, 2018, 08:11:19 AM

Previous topic - Next topic

Knight

I'm trying to make a script run the instant a pawn wears a specific piece of apparel. I've written the script but there's nothing inside the Apparel class that can be overridden that allows for scripts to be run when worn. I tried to create a constructor but this just returns the following error once being spawned into the world:

Root level exception in OnGUI(): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object

Any suggestions? Does "ExposeData()" run once an item is worn? Maybe I could call upon a method there?

Thanks.

Knight

Bump.

This issue is still unsolved and is pretty vital to something I'm currently working on. Any suggestions at all would be greatly appreciated.

DemonEinstein

Look into the AI code that tells pawns to put on apparel. The classes you should look at are those with 'Job' in the name (iirc). There might be some method that runs when a job is completed, which could allow you to do what you're trying to.