0 votes

When add_points as below, an extra random line is created. Not sure why.

$line.add_point(btn_positions[0]) $line.add_point(btn_positions[1])

I have added two points and only one line should be created. However, one random line shoots off from point number one. screenShot of the Issue
Thanks for your help.

in Engine by (100 points)

Your image isn't working. Are you sure your line only contains 2 points? What does this return?


Print is indeed giving 3.

Will try and share the screenshot again.



Here is the code block:

func onbtn1pressed():
if current
button == "none":
currentbutton = "btn1"
$ASP.stream = load("res://SFX/one.wav")
$ASP.stream = load("res://SFX/wrong.wav")

func onbtn2pressed():
if current
button == "btn1":
currentbutton = "btn2"
$ASP.stream = load("res://SFX/two.wav")

    $ASP.stream = load("res://SFX/wrong.wav")

1 Answer

0 votes

Based on the above, I assume one of the following must be happening:

  • You're adding additional point(s) to your line elsewhere in the code
  • You're inadvertently leaving old (previous) points in the line definition
  • You've added one or more points to the Line node itself via the inspector. If this is the case, any points you add via code will be in addition to those assigned in the inspector.

If you really only want 2 points, you could call $line.clear_points() before adding the 2 points in your on_btn2_pressed() function.

by (12,994 points)

Thanks a lot. Works.
Best answer.

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 webmaster@godotengine.org with your username.