I have this file:
2d platformer v355.html (17.1 KB)
So in this part:
for(let i0 in blocks){
if(blocks[i0].type=="melon"&&distance(blocks[i0].position,{x:cube.position.x,y:cube.position.y,z:cube.position.z})<2){
delete_coin_at({x:cube.position.x,y:cube.position.y,z:cube.position.z})
for(i=0;i<10;i++){
melonSlice1 = new THREE.Mesh(new THREE.PlaneGeometry(1,1),melonSliceMaterial)
melonSlice1.position=blocks[i0].position
melonSlice1.Xspeed=Math.random()*2-1
melonSlice1.Yspeed=Math.random()*1
melonSlice1.Rspeed=Math.random()*2-1
melonSlice1.type="melon slice"
blocks[i0].solid=false
scene.add(melonSlice1)
//blocks.push(melonSlice1)
}
catchedCoins.push(blocks[i0])
}
}
for(block1 of blocks){
if(block1.type=="melon slice"){
block1.position.x+=block1.Xspeed
block1.position.y+=block1.Yspeed
block1.rotation.z+=block1.Rspeed
block1.position.y+=gravity
}
}
When i destroy the melon and it dissapear, instead of destroyng and pull out all melon slices moving away. So… any solution? Thanks anyway!
EDIT 1: I tried forward, backwar, left, right, top, bottom, etc. and any solves my problem with that melons. Or are solid, or disappears like a ghost.
EDIT 2: That many attemps, i reached to the melon destruction function:
2d platformer v400.html (19.3 KB)
Looks good, but I want to generate more melon slices. ¿Any help?