0 votes

Hi,

It looks like the coordinates of Line2D (accessed through getpointposition(int)) do not update after the Line2D node is rotated by an angle. The coordinate values printed to the console remain unchanged as the line rotates. Does anybody know if there is a fix/work around for this?

Thanks

asked Feb 28, 2019 in Engine by MangoTree (41 points)

Perhaps you can show us some of the code you use to rotate the Line2D? That'll help to clarify the problem.

The local coordinates don't change if you change the transform (i.e. rotate).
Read here about how to convert local to "global" coordinates. (see xform):
https://docs.godotengine.org/en/3.0/tutorials/math/matrices_and_transforms.html#doc-matrices-and-transforms

Hi, if you run this on a Line2D, it should print the same value (provided you press the right arrow key), even though I would have expected it to change:

func _process(delta):

  • if Input.is _ key _ pressed(KEY _ RIGHT):

    rotation_degrees+=0.5
    print(get _ point _ position(0))
    

Apologies for the incorrect formatting - I'm new to posting on this forum

Hi, thanks for your reply. Using global _ transform.basis _ xform(get _ point _ position(int)) looks like it solves my issue.

1 Answer

+1 vote

Using 'global _ transform.basis _ xform(get _ point _ position(int))' solves the problem I was encountering (it now shows the updated point coordinate after the 'Line2D' node goes through a rotation). Thanks to all for the replies.

answered Feb 28, 2019 by MangoTree (41 points)
edited Mar 1, 2019 by MangoTree
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.