Saturday, April 22, 2023

Trigonometry | Gamedev Math [VIDEO SUMMARY]

In the video "Trigonometry | Gamedev Math" published by Natsu Games, the creator discusses the application of trigonometry in game development, specifically in the context of shooting mechanics in a top-down shooter game. The video explains the basics of trigonometry, including the unit circle, radians, and the trigonometric functions sine, cosine, and tangent, as well as their inverses.


The video begins by introducing trigonometry as the study of relationships between angles and sides of a triangle. The creator emphasizes the importance of understanding the unit circle, which has a radius of 1 and a circumference of 2π. Radians are used to measure angles, with 180 degrees being equivalent to π radians.

The creator then explains that trigonometry only works with right triangles, which have one angle measuring 90 degrees (or π/2 radians). The trigonometric functions sine, cosine, and tangent are introduced, along with the mnemonic "SOHCAHTOA" to remember their definitions: sine is the ratio of the opposite side to the hypotenuse, cosine is the ratio of the adjacent side to the hypotenuse, and tangent is the ratio of the opposite side to the adjacent side.

The video demonstrates how these trigonometric functions can be applied to game development using the example of a top-down shooter game, where the player aims and shoots at a reticle. The creator explains how the position of the reticle relative to the player character can be used to determine the angle at which the player wants to shoot. By using the tangent function and its inverse, the angle can be calculated, and the sine and cosine functions can be used to scale the projectile's speed properly.

To implement a shotgun-style weapon with a spread of projectiles, the creator suggests generating additional angles around the original angle and repeating the process for each projectile. The video also notes that it's helpful to work with degrees when setting up values in a game engine and then converting to radians as needed in code.

The creator briefly mentions spherical coordinates as a way of describing positions in Cartesian space using radiuses, angles, and trigonometric functions. The video concludes by encouraging viewers to think about how trigonometry can be applied to other game development problems involving circles or angles and to ask questions in the comments if they need further clarification.

Throughout the video, the creator provides clear explanations and visual aids to help viewers understand the concepts being discussed. While the video does not delve deeply into advanced trigonometry topics, it serves as a practical introduction to the subject and its applications in game development.