playMaker

Author Topic: Destroy clone objects from scene  (Read 3570 times)

frostkald

  • Playmaker Newbie
  • *
  • Posts: 2
Destroy clone objects from scene
« on: December 23, 2014, 03:47:57 AM »
Hi!

I am very new in game making and I started to make a fantasy rpg game. I have a big problem. When I create an object with playmaker and after that I want to destroy it, the playmaker does not allow to destory because it says:

Destroying assets is not permitted to avoid data loss.


How can I destroy objects from the scene with playmaker?





wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Destroy clone objects from scene
« Reply #1 on: December 23, 2014, 10:41:05 PM »
You are trying to destroy an asset and not a instance.  Create/instantiate an object, then when you want to destroy it, you can do it by tag or variable.  You can tag it 'monster' and destroy object by tag or you can put the game object into a variable and destroy the game object.  Either way, you are trying to detroy an asset.

frostkald

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Destroy clone objects from scene
« Reply #2 on: December 25, 2014, 02:43:48 PM »
And How can I get property a spawned object?

For example:

I have an Ai which has a health script. When I spawn in to the scene and I press a button, I want to set his health to zero.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Destroy clone objects from scene
« Reply #3 on: December 28, 2014, 11:11:03 AM »
you can check this video out

but i think it will be better if you remake your health script in playmaker

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Destroy clone objects from scene
« Reply #4 on: December 29, 2014, 07:52:05 AM »

Skip up to 3:00 mark I think.

You need to do a few things here.

Store the GameObject you spawned
You're spawning a GameObject at runtime so you have to store it in a variable so you can reference it later.

Get your Health script from it
Use Get Component to target that stored GameObject variable and get the component from it (Health script)

Change the Health variable in the script
Use Set Property to target the variable inside the component you just stored from the Get Component action and set it to the value you want.

This is the process to do since it sounds like you're trying to use a Scene object to affect a spawned Prefab from the Project Hierarchy. However you can target components and child gameobjects locally inside a Prefab and it will work when you spawn it. The limitation is between Scene and Project, but it works fine if you drag n drop stuff and contain the linkage inside the Prefab, it can spawn and operate normally because all of the references are local.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D