I’m trying to make a script that randomly spawns enemies (robots and bombs) but the procedurally generated levels generate.js doesn’t work. What script do I need? https://playcanvas.com/project/375374/overview/playhack-2016
You haven’t attached the script to any entity in your game, so it’s not being run
Edit: It won’t work when you have attached it anyway as you have variable naming issues on lines 17, 18 and 19.
- Your ‘Templates’ entity is called ‘Template’ in the Editor.
- You either need to rename the ‘grass’ and ‘house’ variables to ‘ROBOT’ and ‘ModelBomb’ or change line
var tile = (Math.random() > 0.8) ? ROBOT : ModelBomb;
to use ‘grass’ and ‘house’
2 Likes
Duh! I seem to forget that scripts need to be attached to an entity before they will work. Thanks!
1 Like