I’m new to CoSpaces and fairly new to coding in general. I teach 7th & 8th grade technology and they LOVE using CoSpaces. I am creating different scenes for practice. I have created this scene (https://cospac.es/X2dt) with a witch, a vampire, a GROUP of bats, and a cat. I want the witch to circle the vampire until the group of bats collides with her. I have tried every bit of coding I can think of and it still is not working. In this version of the scene she is just circling the vampire forever. When you click on the vampire, the bats attack the witch, but nothing I have tried works to make her stop or break out of the loop. Please, can someone help me?
That’s a fun practice space! Your code was only missing a way to check when the bats have collided with the witch. Below you can find a possible solution .
Simply click the remix button to copy this space and see what code has changed to make the collision detection possible.
Here’s what changed
Witchscript makes use of a variable called
hasCollided. This variable will be set to
truewhen the largest bat (Bat3) collided with the witch. We’re setting up an event handler for this case.
- While the variable
false, we’ll repeat the turn block with a
repeat until- block. This loop acts similar to a
foreverloop, but can be given a condition so it knows when to stop.
I also noticed that the Big Sakurai Bonsai item you used from Google Poly slows down the space a lot and replaced them with the other Bloodwood tree items. If you want to use them in this new version you can find all items you uploaded to the space in the Upload tab under the 3D models category.
Hope this helps!
Thank you SO much! I tried using a variable at one point, but I must have set it up incorrectly.
The remix button is not yet available. Can you add please?
Remixing of CoSpaces is available in the PRO plan - see CoSpaces Pricing for details.
Hope this helps! Let me know if you have any further questions about this.
Geoff @ TechLeap
Perfect, thanks a lot.