Uploaded January 2019 | Updated November 2026, 3 hours ago
Dot Products are a really easy and fun way to compare Vectors in space. When comparing two normalized with a dot product the result will be the cosine of the angle between the two Vectors. This means that for normalized Vectors the results will be:
| Alignment | Result |
| ------------------- | ----------- |
| Parallel | 1 |
| Anti-Parallel | -1 |
| Orthogonal | 0 |
Taking the ArcCosine of these values will return the angle between the two Vectors (Note that Unity uses radians for most calculations so you may need to convert to degrees yourself).
Lets explore some applications of Dot Products and show off how to take advantage of them in your games or other projects. For example, how can you detect if a point is inside of a cone? Perhaps as a way to check if an enemy AI can see the player or another reason. A second example may be detecting the difference in orientation between joysticks and a vehicles orientation to detect if a turn or thrust is the appropriate action to perform when moving.
The formula for dot products is the sum of the product of each axis. For example the dot product of two vectors A and B would be:
* In 2D space: `(A.x * B.x) + (A.y * B.y)`
* In 3D space: `(A.x * B.x) + (A.y * B.y) + (A.z * B.z)`
* In 4D space: `(A.x * B.x) + (A.y * B.y) + (A.z * B.z) + (A.w * B.w)`
* This formula can be expanded as the dimensions continues to increase if you need it to.
Note: Because of this formula the length of the Vectors being compared in the dot product *does* matter!
***
A similar application of dot products but in shader form in our revealing flashlight shader: youtu.be/b4utgRuIekk
An example of using dot products to help control how a top down spaceship uses it's thrusters and rotation: youtu.be/TUIHY-5MvWQ
Source Code for this series is available on GitHub: github.com/WorldOfZero/top-down-spaceship
Join the World of Zero Discord server: discord.gg/hU5Kq2u
Dot Products are a really easy and fun way to compare Vectors in space. When comparing two normalized with a dot product the result will be the cosine of the angle between the two Vectors. This means that for normalized Vectors the results will be:
| Alignment | Result |
| ------------------- | ----------- |
| Parallel | 1 |
| Anti-Parallel | -1 |
| Orthogonal | 0 |
Taking the ArcCosine of these values will return the angle between the two Vectors (Note that Unity uses radians for most calculations so you may need to convert to degrees yourself).
Lets explore some applications of Dot Products and show off how to take advantage of them in your games or other projects. For example, how can you detect if a point is inside of a cone? Perhaps as a way to check if an enemy AI can see the player or another reason. A second example may be detecting the difference in orientation between joysticks and a vehicles orientation to detect if a turn or thrust is the appropriate action to perform when moving.
The formula for dot products is the sum of the product of each axis. For example the dot product of two vectors A and B would be:
* In 2D space: `(A.x * B.x) + (A.y * B.y)`
* In 3D space: `(A.x * B.x) + (A.y * B.y) + (A.z * B.z)`
* In 4D space: `(A.x * B.x) + (A.y * B.y) + (A.z * B.z) + (A.w * B.w)`
* This formula can be expanded as the dimensions continues to increase if you need it to.
Note: Because of this formula the length of the Vectors being compared in the dot product *does* matter!
***
A similar application of dot products but in shader form in our revealing flashlight shader: youtu.be/b4utgRuIekk
An example of using dot products to help control how a top down spaceship uses it's thrusters and rotation: youtu.be/TUIHY-5MvWQ
Source Code for this series is available on GitHub: github.com/WorldOfZero/top-down-spaceship
Join the World of Zero Discord server: discord.gg/hU5Kq2u


 or [Construct](https://www.construct.net/en/make-games/games-editor) as two examples.
My twitch streams are at https://www.twitch.tv/worldofzerodev
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Building OBS Overlays in Unity 3D](https://i.ytimg.com/vi/940uUL0Nvwc/mqdefault.jpg)
.
{{% youtube id=Oq2ytDvHTYM %}}
***
The Unity Animator Controller is documented here: https://docs.unity3d.com/Manual/class-AnimatorController.html
Unity has published a tutorial series on learn.unity.com about using the animator controller: https://learn.unity.com/tutorial/animator-controllers-2019-3
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Animating the Elevator - An Elevator Between Scenes - Part 1](https://i.ytimg.com/vi/96iaO7kl2Xg/mqdefault.jpg)

![Expanding our Mindustry Server with Custom Maps, Saves and More
Lets expand the dockerized Mindustry server weve been building by dynamically downloading the `server.jar` when we build our image and enabling custom maps, automatic hosting, persistent save files and more! Well be taking a look at how we can use volumes to mount local directories in our container so were able to add custom maps or access our servers config files locally. Then well look at using scripts that can automatically start our server using the custom map file we choose when starting our server.
Our expanded Dockerfile looks like this:
```dockerfile
FROM openjdk:25-slim
ARG MINDUSTRY_VERSION
ENV MINDUSTRY_VERSION=${MINDUSTRY_VERSION:-v146}
COPY run-server.sh /mindustry/run-server.sh
ADD https://github.com/Anuken/Mindustry/releases/download/$MINDUSTRY_VERSION/server-release.jar /mindustry/server.jar
CMD [ sh, /mindustry/run-server.sh ]
```
`ADD` lets us add remote files to our container image, this means we can directly link to the github release binaries to add them to the image without having to download them to our computer first.
Our `run-server.sh` script hosts a random map or the map provided in the `MINDUSTRY_MAP` environment variable if you provide it.
```sh
if [ -z ${MINDUSTRY_MAP} ]; then
java -jar /mindustry/server.jar host
else
java -jar /mindustry/server.jar host $MINDUSTRY_MAP
fi
```
Once we have created those two files, we are able to build our server using `docker build`:
```sh
docker build tag mindustry-server build-arg MINDUSTRY_VERSION=v146 .
```
This builds our `mindustry-server` image with the `MINDUSTRY_VERSION` version of Mindustry - in this case `v146`.
Once we have both of these scripts we can run our server using:
```sh
docker run -it -p 6567:6567 -p 6567:6567/udp -v ${pwd}/config:/config -v ${pwd}/maps:/config/maps -e MINDUSTRY_MAP=Veins mindustry-server
```
This command runs a new `Veins` map including our maps and config settings for persistence using volumes.
The current version of this container is available on GitHub at https://github.com/WorldOfZero/mindustry-server
***
Mindustry is available on Itch or Steam for desktop players or you can get a copy for your mobile phones:
* Itch.io: https://anuke.itch.io/mindustry
* Steam: https://store.steampowered.com/app/1127400/Mindustry/
* Google Play Store (Android): https://play.google.com/store/apps/details?id=io.anuke.mindustry&pli=1
* Apple App Store (iOS): https://apps.apple.com/us/app/mindustry/id1385258906?ls=1
(I dont have any association with this game, I just like playing it)
***
If you missed the first video in our Dockerized Mindustry Server, you can catch up here: https://youtu.be/m3mowhqXsXE Expanding our Mindustry Server with Custom Maps, Saves and More](https://i.ytimg.com/vi/9kenUFJqoVc/mqdefault.jpg)




