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?

asked Jan 6, 2019 in Projects by BryanGieger (22 points)

1 Answer

+2 votes
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)
answered Jan 7, 2019 by rojekabc (162 points)
selected Jan 7, 2019 by BryanGieger

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.