playMaker

Author Topic: Copy a component to an other object  (Read 3337 times)

Sly

  • Full Member
  • ***
  • Posts: 123
Copy a component to an other object
« on: November 18, 2014, 08:41:31 AM »
Hello,

I was wondering if it's possible to copy a component from a gameobject to an other via playmaker.

For example: on my first object I want to copy the component rigidbody (or any other component) to my second object. But I want it to keep the same value from my first object.
Is it possible? Or is there a trick to do it?

Thanks in advance.
Have a good one :)

Sly

  • Full Member
  • ***
  • Posts: 123
Re: Copy a component to an other object
« Reply #1 on: November 19, 2014, 10:24:21 AM »
Any idea if it's possible?

600

  • Moderator
  • Hero Member
  • *****
  • Posts: 715
    • Flashing Lights
Re: Copy a component to an other object
« Reply #2 on: November 19, 2014, 11:22:43 AM »
Hi, I dont know about copying, but I do something like this:

I get all properties from first one, then for second gameObject Add component and set properties from the first one.
Usually I check which properties are changed, those are copied, others which I don't touch I leave as default.

Sly

  • Full Member
  • ***
  • Posts: 123
Re: Copy a component to an other object
« Reply #3 on: November 20, 2014, 08:34:35 AM »
Hello 600,

Thanks for your idea 600!
Sadly, I want to do this without having to copy/past properties. To explain, I'm using a component to have my character characteristics, so it could be long to copy/paste those and if I add new character properties, I will need to update my FSM. And it could be long to do that all the time.

--> For now I find a way by creating a child on my character (with my script on it) from a prefab. I follow this thread to understand how to do it:
http://hutonggames.com/playmakerforum/index.php?topic=6939.0

But I really want to know if there is more simple way to do it. Is it possible to copy a component with his values to an other game object with playmaker? Does a custom action exist to do it?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Copy a component to an other object
« Reply #4 on: November 20, 2014, 08:56:31 AM »
Hi,
 
 I am not aware of anything like this at runtime unfortunatly.

 Bye,

 Jean

Sly

  • Full Member
  • ***
  • Posts: 123
Re: Copy a component to an other object
« Reply #5 on: November 21, 2014, 03:03:28 PM »
Yes I found some stuff about it for the unity engine but nothing very official or easy to install.

So like I already said previously, the easy way is to create a child on a target from a prefab.