0 votes

Dear All,

I planned to make a weapon class which is should be instanced by the type of weapon.
It has a dictionary with the weapon names and those attributes. One of attributes is its sprite texture. So I managed to instance an appropriate type weapon in runtime, but i have trouble to set its collision shape.
Is there any way to set the shape from a texture mask? So I dream somethink like this:
for weapon1 collisionshape2d.setshape("res://collisionShapeMask1.png") and for weapon2 collisionshape2d.setshape("res://collisionShapeMask2.png")

Or other idea is I create a lot of collisionshape2d, set its form that reflect the appropriate weapon form and enable/disable in runtime. However it does not seem to nice.

Or should I go with the rookie solution? Make a scene for all weapons and turn enable(show)/disable(hide) those i would like to use?

thank you very much

asked Jul 25 in Projects by marypoppins (12 points)

1 Answer

0 votes

I think a good solution would be to use inheritance et load the correct weapon at runtime.

answered Jul 25 by BraindeadBZH (675 points)
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 How to use this Q&A? before posting your first questions.