Forum rules - please read before posting.

Help needed from anyone (custom playmaker actions) prefab Set ActionAsset and PlayActionAsset

edited September 2014 in Engine development
So I've been trying to wrap my head around this as I'd really like to play some prefab actions from within PlayMaker, 2 things would really benefit me here, 1 being able to store the prefabbed asset / actionlist, and 2 being able to play it as a stored var or from prefab.

Here's what I've done so far and it is terrible:

PlayActionListAssetPM

using UnityEngine;
using System.Collections;
using System;
using AC;

    namespace HutongGames.PlayMaker.Actions
    {

    [ActionCategory("Adventure Creator")]
        [Tooltip("Sends an Interact and runs the asset action...")]
        public class PlayActionListAssetPM : FsmStateAction
        {

        protected AC.ActionListManager actionListManager;

            [Tooltip("Where to send the event.")]
        public AC.ActionListAsset eventTarget;
        private GameObject kz;
            
            [Tooltip("Repeat every frame. Rarely needed.")]
            public bool everyFrame;
            
            
            public override void Reset()
            {
                eventTarget = null;
            }
            public override void OnEnter()
            {
            kz = new GameObject();
            kz.AddComponent<ActionList>();
            ActionList kzScript = kz.GetComponent<ActionList>();
            kzScript.source = ActionListSource.AssetFile;
            kzScript.assetFile = eventTarget;
            kzScript.Interact();
                Finish();
        }

    }
}

SetActionListAssetPMAC

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
    [ActionCategory("Adventure Creator")]
    [Tooltip("Sets the Action List from a Prefab.")]
    public class SetActionListAssetPMAC : FsmStateAction
    {
        [RequiredField]
        [UIHint(UIHint.Variable)]
        public AC.ActionListAsset variable;
        public AC.ActionListAsset gameObject;
        
        public override void Reset()
        {
            variable = null;
            gameObject = null;
        }
        
        public override void OnEnter()
        {
            variable = gameObject;
        }
        
        public override void OnUpdate()
        {
            variable = gameObject;
        }
    }
}


Any help from anyone who can contribute this would be great, thanks.
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.