Forum rules - please read before posting.

AC and PlayMaker duplicate prefabs

edited September 2014 in Technical Q&A
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

  • I appreciate your lengthy description, but I'm still somewhat confused about your setup.  A post of the ActionList with the parameter in question would help.

    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.
  • I think I figured it out on my own. It would be a bit complicated to show with screenshots, so I'll just try to explain briefly in case you're still curious:

    I want to run a "combat" FSM when the player clicks on an enemy with that FSM attached.

    Previously, I used the AC hotspot system to run an actionlist which sends an "attack" event to the "combat" FSM when clicked. I used the Third-Party: Playmaker action to send the event to the enemy game object.

    However, when I save the enemy as a prefab and try to create multiple instances, the actionlist still only refers to the original enemy game object which is in the scene. I realize this is an intended feature of AC, but I was trying to find a way to update the game object field in the action list for each instanced enemy, without creating a cutscene for each individual instance.

    So I decided to use playmaker fully for activating enemies. I still use AC to identify and highlight hotspots, but now I use a mouse pick action in playmaker to activate the appropriate enemy instance, as playmaker makes use of "get parent" or "get owner" actions, which make reusing FSMs for multiple instanced objects much much easier and more efficient.


    It would be nice if AC had a similar "get owner" action but i certainly understand that this isn't necessary for most adventure games. I'm very grateful for how well AC works with playmaker though!
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.