I'm trying to create a single prefab for a particular enemy type, and then allow that prefab to be placed around the scene many times.
The prefab has a hotspot, and I'm using AC to handle the hotspot detection. Right now I have it set to call an asset-based interaction when clicked, which runs another asset-based actionlist that activates two PM FSMs- a manager FSM which calculates the player damage, and one which is specific to each prefab, which calculates enemy health, subtracts damage, does neat effects, etc. This one is called with a parameter- in this case the hotspot and FSM are on the same object, so the actionlist uses a parameter indicating the owner of the script.
This works great for a single enemy, but when I try to duplicate the prefab, I notice that the interaction which the hotspot calls refers to the same actionlist which uses the original object as the parameter for the FSM, and therefore when any of the duplicate hotspots are clicked, only the original enemy is damaged.
I want each duplicated prefab to have a hotspot which calls an interaction that affects its own parent object, not the original object. I can create dozens of new interactions for each enemy, but doing this for an entire game seems like an incredibly big time waster. I want to find a way to duplicate the prefab and simultaneously change the parameter so that it refers to the duplicated parent object, and not the original object.
I understand that this is a feature of AC, and that a single actionlist shouldn't be referring to different objects even when it's duplicated. However, I am at a loss as to how to solve this without completely abandoning the AC hotspot system. Any advice on how to get this done with a custom script or action?
One thought I had was to change the enemy FSM so that it is activated on a click or raycast within a different FSM (unrelated to AC), but I am using the playervicinity hotspot detection method, and I am not quite sure how to only allow this click/raycast event when the hotspot is being detected by AC.
Does anyone have any thoughts?
Comments
The answer may be on inserting a custom Action into the ActionList that basically re-writes the Parameter that gets sent on the fly. Would that be appropriate? Again, I'll need to see your setup before I can confirm this is even possible, but that's my first thought.