Spawn prefabs
import { Service, GameInstance, inject, World, AssetLoader } from '@hology/core/gameplay';
import { Vector3 } from 'three';
@Service()
class Game extends GameInstance {
private world = inject(World)
private assetLoader = inject(AssetLoader)
async onStart() {
const prefab = await this.assetLoader.getPrefabByName('test prefab')
const instance = await this.world.spawnPrefab(prefab, new Vector3(0,0,0))
setTimeout(() => {
this.world.removePrefab(instance)
}, 1000)
}
}
export default Game
Last updated