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)

1 Answer

+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 (164 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.

Type:Error
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);
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.