Should I use multiple scenes as weapons?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bobbydickins
:warning: Old Version Published before Godot 3 was released.

Right now I have a Player scene in my project. Within this scene I also have an instanced scene called “weapon”.

I plan on having multiple weapon types for my project and these weapons would have different values such as fire rate, bullet type, and ammo capacity.

I am curious to know what the best method for organizing these various weapon types is? Right now I have one “weapon” scene which has all my weapon types (Position2ds) as children. Each weapon has its own values (I have export variables on each one) so that I can easily edit them in the weapon scene.

I think the best way to go about actually firing a weapon would be to have a variable in the player script that determines which gun is currently being used. I would then be able to call a fire function and set the proper timer values so that I can instance each bullet properly.

Other methods I have seen people use are Dictionaries and the use of separate scenes for each weapon. Would this be a good way of achieving my goal?

:bust_in_silhouette: Reply From: eons

Making a scene for each weapon may give you flexibility for expansion but may make hard to manage them, at the same time you will be able to attach any script to them making a single weapon with different behaviour many with the same.

A single generic weapon scene may be simple to create but the script is going to need a lot of options for different behaviours, variables and resources (animations, textures) this may make it prone to hard to manage bugs.
Once is done, it should be easier to patch, though.


My advice is to put a (temporary?) limit to the game features and look which approach fits better the design in a short/mid term, later you will be able to expand it with a strong base.

thank you, that makes sense

bobbydickins | 2017-07-27 03:17