Distance between enemy and turret

Hello,
just wanted to ask why we compute the distance of a that way. In a game environment we would know the position of the objects. Using these positions we can then build a vector from the turret to the enemy and compute its length.
Usually we would not store angles between objects. So does this example have practical applications or is it just for purposes of showing the sin rule?

Great question @Donlod!

You’re absolutely right. We generally wouldn’t use this approach to calculate the distance of game objects in the world. Since we have access to their transform position, this gives us much easier ways to calculate the distances between them.

However, the sine and cosine rules do have a lot of applications in more advanced game dev topics, such as custom mesh generation and inverse kinematics, where you don’t necessarily have all of the vertex positions in advance.

I hope that helps.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms