playMaker

Author Topic: Remove and re-add component with same settings [SOLVED]  (Read 2310 times)

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Remove and re-add component with same settings [SOLVED]
« on: November 14, 2013, 01:00:48 AM »
I have a cube object that has a rigidbody attached. When the FSM triggers a change, that rigidbody is removed, and after a set amount of time, using "add component", a new rigidbody is added, and the FSM resets.

How can I ensure that the new Rigidbody retains the settings (mass, etc) of the one that got deleted? I tried the "get component" action, thinking I could store the original rigidbody before deleting it and then re-add it. But, when I assign the "get component" action to the cube, I see that I'm able to create a variable to store the component, but nowhere do I see the option to choose which component to store.

Am I using the "get component" action incorrectly, or is there an entirely different way to ensure that the settings from the removed rgidbody trnafser to the new one?

Any ideas or input greatly appreciated!
« Last Edit: November 14, 2013, 07:16:15 PM by Breadman »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Remove and re-add component with same settings
« Reply #1 on: November 14, 2013, 01:12:51 AM »
Hi,

 for this, you will need to save the properties you want to carry over in some ways.

is these property changed during the game? else you could just use prefabs isn't it?

 I am not too sure I follow your use case and why you must do it this way. disabling component may very well be what you need actually.

bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Remove and re-add component with same settings
« Reply #2 on: November 14, 2013, 01:29:36 AM »
Hi Jean!

I have a large cube which is part of a puzzle. The cube is pushable by the character. For some of the puzzles, the character will push the cube into a passageway to block something dangerous, etc. After a set amount of time, the cube resets its starting position, in case the player messed up the puzzle, or to increase the level of challenge.

However, when the cube resets, I want it to "flicker" back into place. It is during this flickering into place that I want to remove the rigidbody, so that the player can't immediately start pushing it again, until it's done flickering (about .5 seconds), and then re-add the rigidbody with those settings.

That half a second of non-pushability isn't critical, so this isn't a major issue, just something I'm curious about!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Remove and re-add component with same settings
« Reply #3 on: November 14, 2013, 02:07:54 AM »
Hi,

 then yes, you don't need to delete anything, simply set it as "is kinematic" and move the cube in the position, then turn "is kinematic" off again so that it becomes free again.

bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Remove and re-add component with same settings
« Reply #4 on: November 14, 2013, 07:15:59 PM »
That works! Thank you!!