Got the error message after writing the code:
bullet is a variable for the bullets fired from a gun. If you want a closer look at everything the code editor is shooting.js at
In a nutshell, in
bullet is null so it can’t add it to the scene hierarchy.
You are also creating a new entity every frame in
In this scenario, you should be creating a new entity every time you fire and attach it to the scene hierarchy.
Thanks! While you’re here, though, I noticed that after redoing the code, the bullet spawns at the origin and sits there for a second before despawning. How do I
- Set its position to the gun, and
- Move it forward?