Hello!

First of all i'm using Godot 2.1.4.

I've been wrestling for a while now with an issue involving drawing a polygonal line between two coordinates, a fixed coordinate and a moving one, e.g. the user's mouse cursor. Until now i've been unable to successfully calculate the coordinates of each of the corners of this polygon with a given angle without any bizarre effects.

Basically, each of the opposite faces of the polygon have to be perpendicular to the vector that connects the two of them.

I will share with you some of my current implementations to demonstrate my problem. A scene with a 2DNode with any of the scripts below attached is enough

No matter what i try, it always ends up with the same strange result where the opposite faces do not remain perpendicular to the vector connecting both points, and i have no idea what i'm doing wrong. If anyone could help i'd be deeply thankful!

I've uploaded the relevant .gd demo files that demonstrate my issue and dropped the links to those uploaded files herein, since the forum's code formatting feature is buggy to say the least.

I checked out your code. It could be an issue of winding order of the points. I did something similar a while back, but did it a little differently..it allowed me to do a lot more. I thought I would post here in case it helps you get out of your geometry hell...haha

I made a start node that could be a child of a game object node. This node orientates itself to the cursor (or target) and is used to determine the points.

Just posting screenshots of the start node code and end result below. The sprite node is just the godot icon.

Edit - I simplified it compared to my initial post

Hey Haplotyper!

Thank you for your suggestion, strangely though, i came up with a shenanigan to solve my problem. And it was: count the number of unnecessary rotations the polygon did per PI / 4 of rotation, multiply by 4 to get the total of i-have-no-idea-why-this-happens rotations per revolution, multiply by -1 to invert the coordinates rotation and finally divide the angle that i originally used by this value.

This is the magical line: coord_angle /= (-1)*(14.5 * 4)

That is some serious math-fu. You are very brave..haha

5 years later