• Godot Help
  • How to create complex emission shape from code.

Hi, I want to add an elemental system in my game for the weapons, and elemental weapons will have particles around it's shape
for example: an electric sword will have electric around it's blade, similar to how Dying Light does it with their weapon

i know you can create complex emission shape in the editor from this tutorial
https://docs.godotengine.org/en/stable/tutorials/3d/particles/complex_shapes.html
however it doesn't say how to do it via code and i was wondering if it's possible to do that, otherwise i would have to make new GPUParticles3D for every weapon shape for every elements.

  • cybereality Thanks i finally got it working, just changing material of the draw passes are enough for my purpose but i can see a limitation to this, you can't really have multiple really different particles running at the same time (ie: particles shooting in a straight line and particles flying in a circle) because that would require multiples different GPUParticles3D.

    However i do found another thread which asked basically the same thing but in 2D, so if someone else actually want to create a complex emission shape from code, you would have to set the Emission Shape to either Points or Directed Points then generate a texture from code and assign Point Texture with that.

So the electricity is probably just an animated texture (using UV animation in a shader, sort of like a sprite sheet).

For the particles, you could just use a particle engine. You might just be able to have one particle emitter (attached to the weapon) and change the sprite in code.

    cybereality so instead of changing the emission shape inside process material, i should change the material inside draw passes?

    Yes, that is one way to do it. You can change textures on a material with GDScript.

      cybereality Thanks i finally got it working, just changing material of the draw passes are enough for my purpose but i can see a limitation to this, you can't really have multiple really different particles running at the same time (ie: particles shooting in a straight line and particles flying in a circle) because that would require multiples different GPUParticles3D.

      However i do found another thread which asked basically the same thing but in 2D, so if someone else actually want to create a complex emission shape from code, you would have to set the Emission Shape to either Points or Directed Points then generate a texture from code and assign Point Texture with that.