Topic: How to delete clones?

How would I delete clones that have been added to a scene. In my Code snippets post I am able to create them, and I have a counter that can do something once it reaches a number (used it for tracking how many times a key was pressed).

But when I use the deactivate item on the original object from which the clones were made, maratis crashes.

How do I delete the clones individually? Would I have to use that clonelist thing from the wiki in some special way?

http://wiki.maratis3d.org/index.php?title=GetClone

Last edited by Tutorial Doctor (2014-01-30 01:30:05)

Re: How to delete clones?

If i remember correctly you must use something like

toDelete = getObject(getName(cloneList[3])) -- 3 is just for example
deactivate(toDelete)

Re: How to delete clones?

That looks like it would delete the third item in the cloneList table.

I just found out how to use the table.insert function and the table.remove function. But I don't know how to use it to do this.

Re: How to delete clones?

Yep that's it, well taking the example from the wiki,  the very basic usage is :

object = getObject("object")
cloneList = {}

function onSceneUpdate()
   
    if onKeyDown("1") then
        table.insert(cloneList, #cloneList + 1, getClone(object)) -- create a clone
    end

    if onKeyDown("2") then
        toDelete = getObject(getName(cloneList[3])) -- 3 is just for example
        deactivate(toDelete)
    end
   
end

Hope it helps

Re: How to delete clones?

Thanks Vegas. I am trying to get the speed bumps out of the way, I might need this functionality in the future. The code I posted on my post called "Code snippets" can clone a bunch of objects (get's slow when physics are turned on) but I wanted to use them as markers that delete the last clone one a certain number of clones has been created. Once I a decent animated test character I will start making more test levels and code snippets.

Re: How to delete clones?

oops i made a mistake, you don't need getObject nor getName to deactivate the clones in cloneList,
deactivate(cloneList[number]) is enough,

getName is to use with SetBehaviorVariable
example, setBehaviorVariable(Camera, 0, "target", "cloneList[number]") : won't work, it's here
you have to getObject/getName

Re: How to delete clones?

Thank you! When I am finished getting the graphical side of things figured out, I can dig deeper into the code side of things, and these posts will help a lot, thanks!.