playMaker

Author Topic: Enable Component on Prefab from Instance  (Read 564 times)

akaravias

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Enable Component on Prefab from Instance
« on: November 21, 2017, 11:52:53 AM »
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 :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3916
    • View Profile
    • jinxtergames
Re: Enable Component on Prefab from Instance
« Reply #1 on: November 21, 2017, 12:09:03 PM »
Hi,
There is an action called "Activate Component" which you can find on the Ecosystem

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.

akaravias

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Enable Component on Prefab from Instance
« Reply #2 on: November 21, 2017, 12: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

akaravias

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Enable Component on Prefab from Instance
« Reply #3 on: November 21, 2017, 12: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"...

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3916
    • View Profile
    • jinxtergames
Re: Enable Component on Prefab from Instance
« Reply #4 on: November 21, 2017, 05: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 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 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 the get more familiar with playmaker :)