# How can use math for game development?

I have been learning how to script on Roblox for around 7-8 months and have been doing so almost every day. While I understand most of the basics of the syntax of Lua, I still find myself confused whenever I try to create stuff, especially when it comes to using math. It seems like whatever math class taught me is not useful at all when relating to game development, and I struggle to find an example for beginners when it comes to using math in games. I know for a fact that trigonometry is used and I have taken that class and passed it. How can I get pass this barrier? Can someone show me some basic creations that uses some form of trig?

3 Likes

The most basic, and what gave me an intro to basic trig, is building a circle using sine and cosine. Also finding the angle between two points with arctangents. Super simple as far as trig goes, but tons of potential in game design. Granted, they are less useful in Roblox when most trig can be handled with CFrame functions, but I have certainly used them here.

4 Likes

A lot of math I see in Roblox is geometry, vector calculations, and stuff like that. The CFrame object does help a lot with vector manipulation. (under the hood it’s just matrix operations.) Trig also plays a role sometimes when coordinate systems are involved. Whenever I do physics simulations like force vector fields or orbital mechanics I occasionally have to break out my old college calculus textbook to look up integrals or Newton’s method, but there’s never really anything too rigorous.

If you hit a road block chances are whatever problem you’re trying to solve has already been solved, so doing research in places like StackOverflow can be really useful sometimes.

2 Likes

Maths is used in game development. Geometry is mostly used in roblox. But usually in game development these maths are used:

• Algebra
• Trigonometry
• Calculus
• Linear Algebra
• Discrete Mathematics
• Applied Mathematics
1 Like

Yep one creation which uses trig is to find an angle for a turret to rotate to:

Here is the diagram of the problem:

Here is how it can be implemented with Motor6Ds, though it might be more complex as it uses CFrames as well due to how Motor6Ds work.

2 Likes

How did you build a circle? I made a base part rotate around in a circle using the Unit Circle, but that was the most I did that related to math.

Well, that’s about it then. If you wanted to make a Ring out of GUIs or something, you can do something like this, but it sounds like you could figure that out yourself pretty easily. The thing about trigonometry is that, more often than not, you’ll know what you need when you need it and be able to look it up.

``````function getData(rotations, radius)
local coords = {} -- A table the length of 'rotations' containing XY pairs corresponding to points on the circumference
local angle = math.pi*2 / rotations -- The angle between points
local chord = radius*2 * math.sin(angle/2) -- The distance between points, useful if you want to create a part to connect the points. You can also get this with Pythagoras' theorem on the coordinate pairs. I looked this one up, I didn't actually know how to get the chord.
local current = 0
while current < rotations do