+1 vote

Hello,

I have noticed an issue with Line2D when working in C#. I noticed that the points do not update properly when setting the Points array property on the Line2D class.

This does not work:

someLine2D.Points[0] = new Vector2(10, 10);
someLine2D.Points[1] = new Vector2(10, 15);

However ironically enough using the obsolete SetPoints function DOES work:

someLine2D.SetPoints(new Vector2[]{new Vector2(10, 10), new Vector2(10, 15)});

Manually setting the points also works as expected when in GD Script. The issue is only in C# when trying to manually set the points of the Line2D. When in C# the values do not change and stay at (0,0). What could be causing this, and is there a workaround besides what I am doing right now and having the code that controls the Line2D in GD Script for now. Something is not allowing the array to update. Thanks.

Godot version 3.4stable.mono.official
in Engine by (17 points)

1 Answer

0 votes

So after looking at this again with fresh eyes that weren't suffering from sleep deprivation I have remembered that C# properties that handle arrays cannot be indexed like regular arrays. Setting the points array to a new Vector2[] fixes the issue.

by (17 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 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.