Hi everyone,
The eid changed when I setParent for it. I donβt understand why setting the parent affects the referenced eid?
This is my code:
// Set obstacle in row
for (let i = 0; i < obstacleIdArray.length; i++) {
const obstacle = Obstacles.cursor(world, obstacleIdArray[i])
if (obstacle.isReady) {
obstacle.isReady = false
const randomPosX = posXMovingArray[getRandomValue(0, posXMovingArray.length - 1)]
world.setPosition(obstacle.iD, randomPosX, 0, 0)
world.setScale(obstacle.iD, 1, 1, 1)
console.log(`1.1 Set acitve obstacle eid: ${obstacle.iD} -> isReady: ${obstacle.isReady}`)
world.setParent(obstacle.iD, rowObstacle.iD)
console.log(`1.2 Set acitve obstacle eid: ${obstacle.iD} -> isReady: ${obstacle.isReady}`)
if (rowObstacle.obstacleArray === '') {
rowObstacle.obstacleArray += `${obstacle.iD}`
} else {
rowObstacle.obstacleArray += ` ${obstacle.iD}`
}
// Reset collider
world.setParent(obstacle.colliderId, obstacle.iD)
world.setPosition(obstacle.colliderId, 0, 1.45, 0)
world.setScale(obstacle.colliderId, 1, 1, 1)
break
}
}
Console log:
1.1 Set acitve obstacle eid: 721 -> isReady: false
1.2 Set acitve obstacle eid: 759 -> isReady: true