playMaker

Author Topic: Set Property on Variable gameObject?  (Read 760 times)

Wrensey

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Set Property on Variable gameObject?
« on: December 10, 2019, 04:45:16 PM »
is there a way to use the "Set Property" action on a variable gameObject?

I found this old thread but I didn't understand what Kiriri was saying: https://hutonggames.com/playmakerforum/index.php?topic=2791.0

What I am basically trying to do is turn off the collider of a gameObject when the player picks it up. I already have a way of storing the gameObject the player picks up in a variable. I just want to be able to turn off the collider off of the gameObject that is currently stored in that variable when an event fires.

I'm doing it this way because there will be a large variety of different objects the player can pick up and I don't want to add scripts that do this to each object, but I suppose I could if it comes to that.
Follow me on twitter!

daniellogin

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Set Property on Variable gameObject?
« Reply #1 on: December 12, 2019, 12:05:37 AM »
Probably the only way is to have an FSM on each item. I was going to say just copy and paste, but that won't transfer which collider it's turning off. So I guess copy and paste but remember to drag the actual components in for each one.

Wrensey

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Set Property on Variable gameObject?
« Reply #2 on: December 13, 2019, 10:25:54 PM »
Yeah that's what I wound up doing, it's not too bad
Follow me on twitter!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 5546
    • View Profile
    • jinxtergames
Re: Set Property on Variable gameObject?
« Reply #3 on: December 14, 2019, 02:53:46 AM »
Hi,
If you have the object stored you can use 'Enable Collider' action (Ecosystem)

always try to minimize using Get/Set Properties.
As it uses reflection which is slower than dedicated actions.

also you might need to use Linker Wizard else on some platform the actions won't work.
« Last Edit: December 14, 2019, 03:05:28 AM by djaydino »

Wrensey

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Set Property on Variable gameObject?
« Reply #4 on: December 14, 2019, 04:19:52 PM »
Hey 'enable collider' custom action works great! Thanks djaydino!

I didn't know about get/set not working properly on other platforms, I'll try to minimize my use of those, thanks foro the heads up!
Follow me on twitter!

daniellogin

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Set Property on Variable gameObject?
« Reply #5 on: December 16, 2019, 10:47:25 PM »
always try to minimize using Get/Set Properties.
As it uses reflection which is slower than dedicated actions.

also you might need to use Linker Wizard else on some platform the actions won't work.

Heard this before. Have changed the way I do things now (including finding the Activate Object action). However I have opened an old project full of it. I'm wondering if it's always the same no matter what is actually being Set Property? As in, if you use it to disable a Game Object (not change a component), is that still worse than using Activate Object to turn it on and off?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15403
  • Official Playmaker Support
    • View Profile
Re: Set Property on Variable gameObject?
« Reply #6 on: December 16, 2019, 10:58:42 PM »
Hi,

if you do this outside the game loop, it's fine ( like to enable a menu or something), but if it's in your game loop, it could affect perf, but that is still something to verify, cause it could be just fine.

Bye,
 
Jean

daniellogin

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Set Property on Variable gameObject?
« Reply #7 on: December 16, 2019, 11:16:32 PM »
This old project I've got back in to has it for everything, including to enable game objects that have FSMs in them.