How do you change a particle gradient in code

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

I’m trying to dynamically change a CPUPartucle2D’s color gradient but am not sure how
The closest I’ve gotten is this line.


This gives me an error saying that it can’t convert the string to an object. Plus it would cause harsh transitions between gradients if it did work, is there a better way of doing this? I am using GLES2 for better performance on my crappy laptop and web compatibility.

:bust_in_silhouette: Reply From: Mrpaolosarino

It is because you load it improperly.
add this to your global code first:

export(PackedScene) var Broken

then drag the scene to the editor’s parameter


onready var Broken = load(“res://Assets/Objects/Player/Broken.tres”)

Though the first method is performant friendly.
After that, change the code to: