This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
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 (25 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 (385 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 Frequently asked questions and 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 [email protected] with your username.