1
\$\begingroup\$

I'm creating a minimap for my game. There is a mission where the player has to escort an NPC to an area. The minimap shows the player, the NPC and the location. The NPC icon sends an arrow from it's icon on the minimap to the destination location.

The minimap is zoomed in around the player and the location may be farther away then the minimap area, in this case, I put it on the edge of the minimap to make it still visible.

I'm using the dot product to calculate the angle between the NPC and the destination location, using a up vector (0,1). This works until the NPC is on the edge of the minimap. The angle is slightly off and the arrow icon is turned to the side.

I've confirmed both positions on the minimap are correct and the angle between them should be relatively small, but the calculation is too large. I'm unable to post a picture of the minimap here for NDA reasons, but I included a picture of the blueprint.

The arrow icon is facing down, which means it needs to be offset by some degrees depending on the quadrant, thus the addition at the end of the blueprint.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I fixed the bug. The dot product calculation was using cos instead of acos. Changing this fixed the problem.

\$\endgroup\$

You must log in to answer this question.

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