+2 votes

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?

in Engine by (31 points)

1 Answer

+3 votes
Best answer

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.

by (7,946 points)
selected by

thank you, that makes sense

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.