playMaker

Author Topic: How to pass a transform var from playmaker to script?  (Read 3686 times)

ramones

  • Playmaker Newbie
  • *
  • Posts: 42
How to pass a transform var from playmaker to script?
« on: April 02, 2013, 02:45:12 PM »
Hi!,

I would like to pass some transforms vars from playmaker to script. I know I can pass game objects and get the transform from here but I have the transforms cached and would like to reuse them in actions. Is there any way to accomplish this?

Thanks in advance.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support

ramones

  • Playmaker Newbie
  • *
  • Posts: 42
Re: How to pass a transform var from playmaker to script?
« Reply #2 on: April 03, 2013, 08:21:13 AM »
Hi!,

Sorry for the confussion. The transforms are cached at the playmaker side. I mean I have 2 vars with type transforms in the gamemaker variables form.

In my situation I have an action that uses a Transform to do a process. So I have in playmaker a Transform variable that I want to pass to this action.

What I have ended is use a FsmObject in the the action and set the this FsmObject in playmaker to the transform variable. Then in script I cast the FsmObject.Value to transform and use it. Don't know if there's a better way to do this.

I was expenting to have something like FsmTransform to be used in scritable actions.

Thanks in advance.
« Last Edit: April 03, 2013, 08:26:44 AM by ramones »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to pass a transform var from playmaker to script?
« Reply #3 on: April 04, 2013, 01:09:54 AM »
hi,

 ok, the question would be then why do you need to store the transform in playmaker, don't you find what you need as actions already when simply referencing gameObjects? there is a whole section on actions that deal with transforms.

You should cache the transform in the custom action you write, and keep working with FsmGameObject or FsmOwner. Is there a limitation in doing so in your case?

Bye,

 Jean

ramones

  • Playmaker Newbie
  • *
  • Posts: 42
Re: How to pass a transform var from playmaker to script?
« Reply #4 on: April 04, 2013, 02:22:41 AM »
Hi!,

The main reason to store the transform in playmaker is because it is used several times in my FSM. Retrieving components is a relatively slow operation so, I was trying to do things same way I ussually do in script, catch transfrom in the high level and inject it to the differnet processes.

I could catch it in the action but then it would be a bit dumb because the action I was refering does a little process and would have to re-get the transform every time it is called. This is why I wanted to do cach it in play maker.

Perhaps I'm worrying too much about performance at this level but I'm trying different ways to do things too because I'm really starting with playmaker.

Thanks in advance.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to pass a transform var from playmaker to script?
« Reply #5 on: April 04, 2013, 03:38:44 AM »
Hi,

 Yes, I see what you are trying to achieve now. And yes, you may worry about perfs too soon. The key here, is: are you dealing with 100th of them transform, or few? And while you are in deve, you may have only 2 or 3, but what's the real goal when your game will be done? cause refactoring could be a pain down the road. So it's always a dilemna, develop slow because you fear what's coming up down the road or deliver the product and then make it evolve. I prefer number 2, cause too much games and projects stays in the basement and never see the light because of the initial development time was too long.

Now, I think it will be good one day to get a FsmTransform, because I do agree, it's known that caching transforms is a good thing on mobile.

Your solution, if you want to go far with this, is to indeed use FsmObject of type transform, and recreate the related transforms actions to use a FsmObject as its target instead of a GameObject, and then you will have your caching system in place. It would not be too much work, as really you would copy paste the actions you are interested in on a per needed case and start building your custom actions folder as you go.

bye,

 Jean

ramones

  • Playmaker Newbie
  • *
  • Posts: 42
Re: How to pass a transform var from playmaker to script?
« Reply #6 on: April 04, 2013, 06:58:06 AM »
Hi!,

Thanks for the insights. At least I know now that I wasn't doing anything "the wrong way" when using playmaker.

I will try to decide what road to go with this things from now on.

Thanks again for all the time you spend helping us in this community.