Hey, hope someone here can maybe help me:
I've created a shooting_gun scene which will be responsible for firing bullets (and will be added to both player and enemies that can shoot)
the shooting_gun script have a variable called bullet_scene which will be used to instantiate it in the shoot function so i can basically make it shoot anything i want not just "bullets"
if (_current_shooting_time < shooting_speed):
return
var bullet = bullet_scene.instantiate()
bullet.position = global_position
bullet.direction = shooting_direction
owner.get_parent().add_child(bullet)
_current_shooting_time = 0
For now I just have bullet_scene that just move on the x axis but in the future I can create more types like homing_bullet scene that will seek targets, etc
This sounds good but I ran into a problem: Currently both the player and the enemy using the same bullet_scene with the same sprite texture but I want enemies to shooting different sprite texture.
The way I do it right now I am not able to customize the texture in a modular way. I can have a variable on the shooting_gun scene called bullet_texture and then change the bullet sprite texture after I instantiate it but what if the "bullet" I instantiate does not have a texture . I want the shooting_gun scene to not care about how the "bullet" is implemented just be responsible for the firing mechanic (if that make sense)
My player.gd script:
shooting_gun.shooting_direction = Vector2.RIGHT
shooting_gun.shooting_speed = 0.2
shooting_gun.bullet_scene = bullet_scene
# how to change the bullet scene sprite here?!
```
I wonder if this is a bad approach and maybe I need to find a different approach to tackle this issue?
Hope that question make sense.