1
\$\begingroup\$

I am doodling on the Flying game template on UE4. I am making a 2D radar on top left. Radar's north direction is the pawn's forward direction. So when it approaches to an object with the dotProduct value of 1, dot representing the enemy object on the map has to approach from direction (0, -1) on the coordinate system. Just like any shooter game.

My problem:

As I know, to calculate the x,y positions on the coordinate system with given angle and distance, the formula is as follows;

x = Cos(𝛉) * dist, y = sin(𝛉) * dist

As Unreal Engine's UI classes use top left as the pivot point, if an object is on absolute north of the origin on the screen, it has to come from (0,-1) as I wrote above.

Cos(270), sin(270) has to give 0,-1 and when I multiply with the distance, the dot has to be shown on absolute north of the origin point of the radar.

I declared two UProperties to play with the angles on the editor on runtime. When I enter 270, 270 for cos and sin values, it shows the dot as on the image below;

270,270

the closest to the top left is when I enter -90, 90 and it shows like in the image below;

enter image description here

Even if I am entering the incorrect values, I think at least an angle such as 90, 90 has to be perpendicular. Does anyone have any idea?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Are you sure cos and sine take degree and not radians? Try to convert your argument into radians and see what happens:

radians = degrees * PI / 180

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .