playMaker

Author Topic: Storing a behaviour as a variable.  (Read 497 times)

Jake_

  • Playmaker Newbie
  • *
  • Posts: 3
Storing a behaviour as a variable.
« on: March 16, 2023, 07:57:50 AM »
Hi!

I'm wondering is there a method built-in to base PlayMaker for storing behaviours as a variable, so that they can be used with CallMethod? For my use case, I will be instantiating an object, and calling a method with multiple parameters, so I will be getting reference to the instantiated object elsewhere in an fsm, storing it as a global, and wanting to call a method through this variable. The default CallMethod action only works for me if I am manually assigning the script to the behaviour field; is there anyway to do this with instantiated objects / variables?

Thanks

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Storing a behaviour as a variable.
« Reply #1 on: March 16, 2023, 10:24:53 AM »
Hi.
Its best to create a custom action for that.

here are some tutorials :

https://www.youtube.com/results?search_query=playmaker+custom+action


Jake_

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Storing a behaviour as a variable.
« Reply #2 on: March 16, 2023, 02:00:46 PM »
Hi.
Its best to create a custom action for that.

here are some tutorials :

https://www.youtube.com/results?search_query=playmaker+custom+action

Thanks, I've been playing around with this a bit. I've hit a bit of a wall, in that I can't seem to actually store the component / behaviour in a way this is useful for CallMethod.

I can get a reference to the component, but I can't store it as a variable or in a way that CallMethod can see in the behaviour field. Looking at the vanilla GetComponent action, there is a storeComponent property that I can't seem to get working or actually storing the component.

That leads me to believe that the best approach may be a custom action for finding the behaviour and then executing CallMethod in the same action with the found component, instead of trying to store and access between multiple actions. Does that sound right?

Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254
Re: Storing a behaviour as a variable.
« Reply #3 on: March 16, 2023, 10:59:08 PM »
Forget about the call method action entirely. Your custom action will call the method and pass the needed parameters to the instantiated object.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Storing a behaviour as a variable.
« Reply #4 on: March 17, 2023, 01:47:40 AM »
Hi.
You can store as a Object and add the object type

Code: [Select]
        [ObjectType(typeof(DroneSkill))]
        public FsmObject droneSkill;

Jake_

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Storing a behaviour as a variable.
« Reply #5 on: March 17, 2023, 07:30:40 AM »
Thanks for the help, I've gotten to the bottom of this this morning. The storing as object was not working, but I've got a solution working that lets me enter behaviours and methods and call functions with X parameters. The action UI is a bit ugly (can't seem to get a dropdown with available methods to work, but I have one to select behaviours) but it works.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Storing a behaviour as a variable.
« Reply #6 on: March 17, 2023, 11:52:22 PM »
Hi.
are you connecting to the Script directly?

maybe you can share the code of the action you made so we can check if there are no issues on it :)