Tools

Dot product, visualised

Drag two arrows: is the enemy in front of me, inside the view cone, and at what angle?

Runs locally — nothing leaves your browser

How to use it

  1. Drag the bright arrow to turn the actor, and the dot to move the target. Or type the numbers.
  2. Watch the dot product: 1 straight ahead, 0 exactly to the side, −1 straight behind.
  3. Set the view cone, then copy the threshold or the C++ check into your project.

Your scene, from above

Actor and target

The dot product of two direction vectors says how much they point the same way. Your forward vector and the direction to an enemy give one number that answers “is it in front of me?”.

°

0 faces +X (forward). Positive turns to the right, towards +Y.

In Unreal Details → Transform → Rotation → Z (Yaw)

cm

Where the target is, relative to the actor. 100 Unreal units = 1 m.

cm
°

How far to each side the actor can see. 45° means a 90° wide cone.

Try a position

The result

What the dot product says

Top-down view of the actor, its view cone and the target

Dot product
—
−1 … 1
Angle
—
Acos (Degrees) of the dot.
Side
—
Sign of the dot with the right vector.
Distance
—
The dot ignores it.
  • Cone threshold — compare the dot with it (≥) —
  • C++ — the same check —
In Blueprints the five nodes
  1. Get Actor Location of the target, minus Get Actor Location of yourself: the vector to the target.
  2. Normalize it, so its length is 1. Or use Get Unit Direction (Vector) for both steps.
  3. Get Actor Forward Vector of yourself — already length 1.
  4. Dot Product of the two. Above 0 means in front.
  5. >= the cone threshold below. True means inside the view cone.

For a flat cone that ignores height, set Z of the vector to the target to 0 before normalizing. Otherwise an enemy far above or below you can fall outside the cone.

How it works

What the number means

For two vectors of length 1, the dot product is the cosine of the angle between them: 1 when they point the same way, 0 at a right angle, −1 when they point opposite ways. That is why the direction to the target must be normalized first — with a longer vector the result also grows with distance.

  • In front or behind: the dot of your forward vector and the direction to the target is above or below 0.
  • View cone: compare the dot with the cosine of the half-angle (Cos (Degrees) in Blueprints). 45° → 0.7071.
  • Left or right: the same test with your right vector — positive is right, negative is left.
  • The angle itself: Acos (Degrees) of the dot. Comparing dots is cheaper than comparing angles.

Unreal’s axes

X is forward, Y is right, Z is up, and positive yaw turns from X towards Y. The view here is from above with forward pointing up. Heights are ignored, like a guard that sees in a flat cone.

Privacy

Everything runs in your browser. Nothing you enter is sent anywhere.

Newsletter

Development updates are coming to your inbox.

The newsletter opens soon. Until then, new lessons, tools and Beach Hunters progress appear first on our channels, linked below.