Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: akaravias on November 21, 2017, 01:52:53 PM

Title: Enable Component on Prefab from Instance
Post by: akaravias on November 21, 2017, 01:52:53 PM
Hi there,

New to Unity and first time forum poster here! :)  I had a search online and quickly in the forum search and couldn't find an answer to this (at least that i could understand)...

- So basically, i have a Prefab user controller Space Ship
- I have an Instanced 'Boss' character..
- When the boss character is destroyed, i want to turn on the Animator Component on my Prefab Space Ship, from an FSM on the Instanced Boss character...

I can't work out how to do it :(  I used Find Object for the other bits i needed, such as turning off an FSM from my spaceship prefab, but still can't work out how to turn off the Animator component from an FSM on the Instanced Boss Character..

Any ideas?? :/

Thanks very much :)
Title: Re: Enable Component on Prefab from Instance
Post by: djaydino on November 21, 2017, 02:09:03 PM
Hi,
There is an action called "Activate Component" which you can find on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)

is your Prefab Space Ship created @ runtime?
If so you can store the object directly within the 'Create Object' action, so you do not need to find it anymore.
If you need to get it from another fsm then you can use "Get Fsm..." actions.
Title: Re: Enable Component on Prefab from Instance
Post by: akaravias on November 21, 2017, 02:20:53 PM
Thanks very much! Nice tip about the "Create player/find object" scenario too :) I was already storing it but didn't have it as a global variable so forgot about it. Nice bit of cleaning up/refactoring :)

So ecosystem is a seperate addon for playmaker? Thats a little concerning. As in, i'm already getting a little confused and didn't want to add complications to things. It seems like it should be a fairly straight forward function already built in. But oh well, i'll give it a shot.

Thanks very much for your reply, really appreciate it. I'll let you know how it goes :D
Title: Re: Enable Component on Prefab from Instance
Post by: akaravias on November 21, 2017, 02:39:53 PM
Is this any different from using "set property" ?  It doesn't seem to have any options for selecting stored prefabs i.e from "find object"...
Title: Re: Enable Component on Prefab from Instance
Post by: djaydino on November 21, 2017, 07:33:40 PM
Hi,
Get/Set Properties are slower as it needs to do more to get what it needs, are limited and you need to use Linker wizard (http://hutonggames.com/playmakerforum/index.php?topic=11126.0) to avoid them to break when you build a game to a platform.

Get/Set Properties and made to use with 3th party component which do not have actions for it.

On the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) you can find many custom actions/bundles/samples
(like 'Ugui proxy full' for example which is used for the newer unity gui)

So it is best always to look there before using 'Get/Set Properties'
and if you can't find what you need, there is also a action request on the forum where you can request actions you can't find.

Another thing, try to avoid using global variables
They are easier to hack and when you got a lot, it tends to get hard to find what they are for. you can use get/set Fsm actions to get/set variables on/from onther fsms. :)

Also you can find many interesting tutorials on the user tutorial wiki page (https://hutonggames.fogbugz.com/default.asp?W548) the get more familiar with playmaker :)