0 votes

I have a particle texture that I want to rotate when the player rotates. It seems the only property for doing this is "Angle" under "process_materials". The problem is I can't access Angle through code. Is there another way to do it?

in Engine by (352 points)

1 Answer

+1 vote

Godot's ParticleEmitter2D is a bit limited in terms of controlling individual control of particles, which means, that setting the random parameters and ramps is about as far as it gets for that, which is enough for a lot of cases though! But in return for that, the engine's ease of use is undefeated.

However, if you're fine with that, you can easily access all the parameters of the ParticlesMaterial.

Try this:

var mat = $Particles2D.get_process_material()
mat.angle = 45 / idk right now if it's in radians or degrees
mat.angular_velocity = 3

# setter version
mat.set_angle(45)
mat.set_angular_velocity(3)
by (840 points)

I just tried the code but according to code completions, I can't find a

.get_process_material()

Maybe because code completion doesn't work for references. I've encountered some weird exceptions (not meaning the runtime error), but the normal case is it won't work. Fortunately, Godot has a quickly accessible built-in documentation. Look to the right corner in your script tab and you'll see the tab "Search help".

Also, code completion sometimes doesn't find some functions, idk why, but look at the documentation to find the right functions. I've tested what I wrote and it works.

Hope this helps.

That's crazy! It worked. Thank you so much. This function isn't in the docs at all. I and anyone else with this problem wouldn't even know this was possible. How do we get this added to the docs and autocomplete?

Glad it helped. Well, there's proably a good reason, why it won't work with references. Idk for sure, but I assume it's because of dynamic typing. So, since the reference could be of any data type, the editor is unable to provide proper code completion.

Yes, that may be true, but it should be documented at least

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.