Code for the characters

30 views
Skip to first unread message

Jowito 2000

unread,
Oct 4, 2017, 2:00:32 PM10/4/17
to CoSpaces

Is there any code for example when we create a cube; Scene.createItem('Cube')-----but for the payment characters. for example is there any, 'LP_Man' for the fancy man that you unlock buying it???

Benjamin Singh

unread,
Oct 5, 2017, 5:34:14 AM10/5/17
to CoSpaces
At the moment it's not possible to use Scene.createItem() for objects from the marketplace. But you can have the same functionality using our internal Scene.copyItem() method. But please note, this method is internal and can change.

1. Drag the object into your scene.
2. "Hide" the object by placing it below the surface (negative z value) with JS.
3. Use it for Scene.copyItem(obj) method which takes an object to copy as an argument and returns a new instance of this object.

Example script:

var pirate = Scene.getItem('pirate');
pirate
.setPosition(0, 0, -3);                   // hide original object

for(var i = 0; i < 10; i++) {
   
var pirateCopy = Scene.copyItem(pirate);    // make copy from original object
    pirateCopy
.setPosition(i, i, 0);
}

Link to example: https://cospac.es/B0UN

I hope this helps.

Benjamin
Reply all
Reply to author
Forward
0 new messages