Member-only story
Let’s talk about the dot product in game development
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?
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…