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 wanted to know if you can change the Velocity variable of AngularVelocity with code:
enter image description here
I'm new to Godot and C # but I think it's done with the code:

var particles = (Particles2D)GetNode("Particles2D");
particles.   ...ETC.

If I am wrong correct me and please can you teach me how to do it?

in Engine by (24 points)

2 Answers

+1 vote
Best answer

If you go a mouse pointer over your property, you'll see a name of property. For angular velocity property name is angular_velocity. So, to set the value, for example, 2.5 of it, in your sample, you should do something like this:

particles.material.set("angular_velocity", 2.5)
by (166 points)
selected by

I tried the following code:

var particles = (Particles2D)GetNode("Particles2D");
if (Input.IsActionPressed("ui_right))
  particles.Material.Set("angular_velocity", 2);

But I get this error:

0:00:05:0402 - System.NullReferenceException: Object reference not set to an instance of an object.

Description: System.NullReferenceException: Object reference not set to an instance of an object.
Time: 0:00:05:0402
C Error: Unhandled exception
C Source: /home/bryangieger/GodotProjects/SpaceShooter/Player.cs:32
C Function: void Player._Process(Single )

UPDATE: The following code has worked.

particles.ProcessMaterial.Set("angular_velocity", 2);
+1 vote

v3.4.2 gdscript example:

$MyParticles2D.process_material.set("emission_sphere_radius", 5)
by (44 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.