Hi there! I try to recreate this effect from Spark to Lens.
Can’t repeat it to use the particles system
also, I found some info about prefab using instance Prefabs - Lens Studio by Snap Inc.
but I guess its not an option.
Hi there! I try to recreate this effect from Spark to Lens.
Can’t repeat it to use the particles system
also, I found some info about prefab using instance Prefabs - Lens Studio by Snap Inc.
but I guess its not an option.
You can dynamically instantiate scene objects with a script. Here’s the docs for the method:
Sorry @josh_beckwith but I’m not a coder and don’t get how to use it. Anyway, I found Jonathan Solichin template and add a camera with device detection. Also, I add device detection to my particle object. But its still working not correctly
Now it looks like this on simulation https://youtu.be/BrjqXBdBm-c
But inside an app, it doesn’t even show anything.
Here is my project:
https://drive.google.com/drive/folders/1IvuXqthsTthC6YP9XOy0rLuRkkkBCMU4?usp=sharing
It seems like pretty much everything in LS requires scripting. They are always talking about how “codeless” it is but I’m not convinced. From what I see, most of the capabilities are scripted. I haven’t been able to make anything custom in LS without using scripts, and the new node graph is basically the same as writing scripts. It might be time to learn scripting
Is this the example project? Particle question – Lens Studio Community
In the simulator, I think you just need to move backward to see the particle emitter. I selected an environment and pressed the “s” key to go backward and then I could see the emitter.
Yes, exactly, this one. I see that particles spawn on 0 points of the screen and I can’t move it from that point.
Every time when I try to create something with scrip I found the way to build it without script but I guess not this time =(
Ok, I solved this one. But now its create not enough objects.
i have two scripts.
One for Look AT function
function onBackCamEvent(eventData) {
for (var i = 0; i < script.getSceneObject().getChildrenCount(); i++) {
var childObject = script.getSceneObject().getChild(i);
if (childObject) {
childObject.enabled = true;
}
}
}
var cameraBackEvent = script.createEvent(“CameraBackEvent”);
cameraBackEvent.bind(onBackCamEvent);
and second
var sourceTr = script.objectToBeSpawned.getTransform();
// Store objectToBeSpawned’s original position and rotation
var oldPos = sourceTr.getWorldPosition();
var oldRot = sourceTr.getWorldRotation();
// Set objectToBeSpawned’s position and rotation to match positionTarget
var targetTr = script.positionTarget.getTransform();
sourceTr.setWorldPosition(targetTr.getWorldPosition());
// Create a new SceneObject
var newObj = global.scene.createSceneObject(“copy”);
// Copy objectToBeSpawned into newObj
newObj.copyWholeHierarchy(script.objectToBeSpawned);
// Restore objectToBeSpawned’s original position and rotation
sourceTr.setWorldPosition(oldPos);
sourceTr.setWorldRotation(oldRot);
so, how can I create more objects on the scene?
I think you can add a for-loop around the creation calls, like this:
for (var i = 0; i < 20; i++) {
var newObj = global.scene.createSceneObject(“copy”);
newObj.copyWholeHierarchy(script.objectToBeSpawned);
}
But this will probably spawn them all in the same location/orientation, so you may want to add some randomness to the rotation/positions on each iteration.
Hm, I try this but its ruin Lens Studio everytime =(
Oh does it crash or something? Spark was very sensitive about object instantiation too…
Lens studio app just like 2 fps with i < 2, and device the same, but if I try i < 20 its just stop working
Anyway
I trying this method
But its hard to understand how to use it with cube mesh builder
https://lensstudio.snapchat.com/api/classes/MeshBuilder/