How to set the scale of a particle 2D node in code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By javrocks

My particle 2d node acts as a Shockwave. When i instance the scene i want the shockwave to be smaller (i.e the scale to be smaller)

extends Area2D

export(PackedScene) var Shockwave: PackedScene = preload("res://Scenes/ShockwaveEmitter.tscn")

func _ready():


func instance(current_node: Node) -> void:
    if not current_node == self:

    var scene_instance = (Shockwave.instance())
    scene_instance.global_position = global_position 
    scene_instance.emitting = true

I don’t know the function that would change the scale that’s in Process material. .scale_amount_set_param(2) dosen’t work

Which type is your Node?

Ando | 2022-08-04 08:43

:bust_in_silhouette: Reply From: Inces

Perhaps shader You used doesn’t use size of particle, but rather has its own parameters. Paste the shader code.

The shader dosen’t have a code/script

The Particle 2d is in a seperate scene. I just instance it and turn emiiting to true.

javrocks | 2022-08-03 19:11

So You used properties of built-in particle material. It also has a scale of singular particle, You can find it there and change it. Or just change the scale of whole Particle2d node, if You whant the whole emission shape to be smaller along with particles.

Inces | 2022-08-03 19:18

Yes i could just change the scale in Process material. But sometimes i need a big shock wave and sometimes i need a small shockwave. Which is why i thought it would be best to change the scale of the node to the appropriate size as it is being instanced.

However scene_instance.get_node(“.”).scale_amount_set_param(4) dosen’t wrk

javrocks | 2022-08-03 19:41

I don’t recognize this scalemaountsetparam function of yours. Why can’t You just adress material and its scale parameter like :

referencetoyourinstance.process_material.scale = 2.0 

Yet for this to work, You need to set local_to_the_scene in material.resource to true in editor, in your original scene

is it Godot 3.4 ?

Inces | 2022-08-03 20:29

Thank u. .process_material.scale = 2 was what i needed.

I was trying set_scale = 2 … and set_amount_scale = 2 and set_param(2)

and they weren’t doing anything

javrocks | 2022-08-03 22:18

glad I helped :slight_smile:
However, if You don’t set local_to_the_scene as I suggested, You will notice, that every time You change the scale like this, it will affect all other currently emitting particles of the same type :wink:

Inces | 2022-08-04 14:50