Topic: Why isn't this clone script working?[solved]

man=getObject("Man")
manPosition = getPosition("Man")
marker = getObject("Marker")


function setMarker()
    if isKeyPressed("M") then
        markerClone = getClone(marker)
        setPosition(markerClone,{manPosition[1],manPosition[2] -10 ,manPosition[3]})
    end
end

It keeps freezing. The setMarker() function is called under the onSceneUpdate() function.

Edit: Nevermind, I got it working:

function offsetClone(object,offset)
    if onKeyUp("O") then
        objectPosition = getPosition(object)
        objectClone = getClone(object)
        setPosition(objectClone,{objectPosition[1] ,objectPosition[2] + offset,objectPosition[3]})
    end
end

This is also called under the onSceneUpdate() function. I changed it to onKeyUp() so that objects wouldn't be continuously spawning while the key is held.

Last edited by Tutorial Doctor (2014-03-21 02:40:27)

Re: Why isn't this clone script working?[solved]

This small script works very well. I can clone a bunch of objects and it still runs fast. Perhaps I will start posting some code snippets.