Let’s talk about the dot product in game development

BlueBubbleBee
7 min readJan 27, 2021

How to use the dot product operation in Unreal Engine using C++ and Blueprints

When I work on gameplay mechanics, I often stumbled across situations where I need to apply maths.
When implementing my NPC (Non-player characters), I face a similar situation like the example I will show you here.

The dot product operation is one of them, it’s handy!
In this example, we have an intimidating giant blue cat stares at my salmon sashimi….

Don’t worry, the cat is friendly and only looks at you if you are facing it, and right there we have a clear situation where we can apply the dot product.
Am I facing the cat or not?

Hey kitty kitty, I offer you this delicious meal if you tell me your secrets…Hey kitty kitty, tell me your secrets

To illustrate this example, I am using C++ and Blueprints on Unreal Engine 4.26.

You can follow the video tutorial here and the project files here.

Dot Product Concept

The dot product is an operation between 2 vectors, which returns a float number.

  • If Dot Product is greater than 0, the cat and the robot face the same…

--

--

BlueBubbleBee

I am Bee, an indie developer making Kitori Academy a cosy life sim where you take the role of a wizard apprentice and have a cat as a companion!