0 votes

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

$SmokeParticle.setcolor_ramp(“res://Assets/Objects/Player/Broken.tres”)

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.

Godot version v3.2.2-stable - 64 bit - Windows
in Engine by (18 points)
edited by

1 Answer

0 votes

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

or

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

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

$SmokeParticle.process_material.set("color_ramp",Broken)
by (378 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.
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 webmaster@godotengine.org with your username.