instantiate render layer
Hi
I'm instantiating copies of my balloon-prefab.
The original prefab is on top af the facemask (in yellow circle), but all copies of the balloon ends up behind the facemask.
How do I fix this?
This is my hierarchy:
And I've used this code to spawn new instances (set on "balloons" <-- small "b"):
// -----JS CODE-----
// @input Asset.ObjectPrefab prefab
//get random position
function getRndInteger(min, max) {
return Math.floor(Math.random() * (max - min) ) + min;
}
function spawn() {
if(script.prefab) {
var newObj = script.prefab.instantiate(script.getSceneObject());
var x = getRndInteger(-15, 15);
var y = -40;
var z = getRndInteger(-13, -5);
var newPos = new vec3(x, y, z);
newObj.getTransform().setWorldPosition(newPos);
return newObj;
} else {
return undefined;
}
}
spawn();
It's all in the same tree
that's why they show behind the first one
But they are not...
The original instance of "balloon" is on top of "Face Mask 1"
The following instances get shown behind "Face Mask 1"
The problem is not that the placement of the balloons in regards to each other, but in regard to the Face Mask.
Hi, Rasmus Lassesen!
The issue might be - when you instantiate a balloon you set its world position. At the moment of time the head can be at any depth from the camera. I would suggest you setting a Local Position of Balloon. Then you can control it's z position relatively to a facemask, which is also a child of a Head
Hope this works
Best
Olha