Scripting

Search The Documentation:

  1. Home
  2. Docs
  3. Scripting
  4. Examples
  5. Clone On Click

Clone On Click

Platform Compatibility

PC Mac OSX Oculus Quest
X X X

This is an example of how to clone an object with SpecialFX tag when clicking the object the script is attached to.

For further reading, look at Tags, tryStore, Timers, and cloneObject!

1
2
3
4
5
6
7
8
9
10
11
12
--Clone an object tagged with "SpecialFX" at the base of the object this script is attached to
--This also uses a 1.0s cooldown timer before another can be spawned
obj.setTimer("cooldown", 1.0, "")

local original = obj.tryStore("SpecialFX")

function onClick(type)
    if obj.timerDone("cooldown") then
        obj.cloneObject(original, obj.getX(), obj.getY(), obj.getZ())
        obj.resetTimer("cooldown")
    end
end
Tags
Was this article helpful to you? Yes No

How can we help?