Shooting projectiles
We’ve sent enough enemies at the player without them being able to defend themselves. Let’s change that in this section! We’ll be creating projectiles the player character automatically shoots at enemies to kill them off. To keep it simple, we’ll make the projectile hone in on the target we are trying to hit; this way, it never misses.
Creating the base scene
Before we can shoot the projectiles, we’ll have to construct the base scene we’ll work from. Let’s do that right now with the following steps:
- Create a new scene that has a Node2D node as the root node and call it
Projectile
. - Create a scene structure as shown next:
Figure 10.41 – The scene tree of the projectile scene
- Use one of the textures from
assets/sprites/projectils/
as the texture for the sprite. Remember to set the scale of the sprite to(
3, 3)
:
Figure 10.42...