#Help needed with scripting!

9 messages · Page 1 of 1 (latest)

timber grove
#

Hi everyone! I'm working on creating a Snapchat lens and need help with scripting in Lens Studio. The script should be able to move an object to a random position within a certain radius around me every time I click on it. Does anyone here have experience with this and can offer some tips?

#

I need to have the same effect as a Ender dragon egg from Minecraft (Sudden and quick teleportation) lol

timber grove
#

Made a simple script, but can't get it to work with the object...

#

//@input SceneObject dragonEgg
//@input float radius = 1.0

function getRandomPosition(radius) {
var angle = Math.random() * Math.PI * 2;
var x = Math.cos(angle) * radius;
var z = Math.sin(angle) * radius;
return new vec3(x, 0, z);
}

function onTap(eventData) {
var randomPosition = getRandomPosition(script.radius);
script.dragonEgg.getTransform().setLocalPosition(randomPosition);
}

var tapEvent = script.createEvent("TapEvent");
tapEvent.bind(onTap);

gleaming smelt
#

You mean tap should work only on the object and not on entire screen.

spare walrus
gleaming smelt
spare walrus