Math for game development

Recommended Posts

I'm starting now in the world of game development and I was wondering if you guys have advice regarding math, what should I learn, maybe some tricks, tips and so on.

I think that this thread would help a lot of other users that is a newbie just like me.

Share on other sites

Normal Algebra,  Linear Algebra.   Very core, and pretty useful.

Calculus typically not useful, since you can follow guides or similar.   Though sometimes being able to make your own derivative can be useful(IE ripping apart an equation designed to be graphed, to be used with your timing system).

Trig occasionally useful.  Normally is handled with linear algebra/Matrix math.   Though can be very useful for some quick and dirty solutions.

Geometry.   could be useful depending on your game type.

Math Intuition can save you hours/days of time.   Actually understanding and apply math concepts will be pretty useful.   Just simple things like knowing you can use trig functions to plot a circle, being able to rip equations apart into multi part steps, being able to decide if approximations are good enough/not, and especially useful when you know enough to know that there should be an easier way.

Big 0 Notation(computer science).   Or rather understanding the costs of different data/looping structures probably won't matter very much at the scale most games work at.   Though can matter if you're making something that has "A LOT"(enemies/terrain/something).

__________

Most games normally use basic math to achieve most effects, in cases where more extreme forms of math are used it's normally put behind something simpler(IE 3D effects/shading/similar put behind a matrix or shader).   Also if you utterly fail at a branch like calc or geometry, you can always just use some other branch or Intuition to work your way out of the problem.

You'll even end up using something like calculus without even realizing you are when you make a simple platformer.   Though even then you won't see anything more complex than some simple multiplication or division when everything is put together.

EDIT:  This isn't to say you won't be needing math.   But when it comes to normal everyday programming it's not as important/complex as it's made out to be.    Personally I think that a lot of it is just carry over from the first computers actually only being useful to mathematicians/code breakers and other super math heavy fields.

Also worth noting that you can also force your game designs away from what you're bad at.   If you're bad at Algebra and Intuition(or calculus) stay away from platformers, if you're bad at data structures stay away from puzzle games, or similar.

Share on other sites

Thank you very much for you answer. I was concern about that you know, I thought I needed to be Chuck Norris in math to create something,

I aim to create a kind of platform game and I was reading a source code of game, there was a lot of trig functions that I was kinda lost, for that reason I downloaded a few videos on the internet for math learning.

I think that if I have the basic understanding of sin, cos, abs, pi and other math functions, it will make things easier to understand and create.

I'm definitely not going to be focusing on theory only, I have to practice - so I can improve the theory, I have to start... procrastination is killing me.

Share on other sites

You'll end up being far better at math than a normal person, though to start your initial skill doesn't matter as much as you'd think.  look at the age that some  programmers start 9-12 while there is some "magic" there(mostly access to better tutors), they were not born with a natural understanding/knowledge of math.

You'll just end up banging your head against a wall until you become better.  Your biggest issues will be not having the intuitive understanding of some things, or knowing enough to be able to google-fu your way out of a problem(past experience when I was younger).   But that is simpler to fix when you have access to tools like khan academy and other primers.

Share on other sites

You may find this tutorials on YouTube useful :

Share on other sites

I suggest you to read 3D Math Primer for Graphics and Games Development book. You can start off with the 2D parts (vectors, normals, distance, etc), then you can expand more if needed.

Share on other sites
9 hours ago, Abhishek Bharti said:

You may find this tutorials on YouTube useful :

Oh gosh, you are a life savior.

9 hours ago, Alectora said:

I suggest you to read 3D Math Primer for Graphics and Games Development book. You can start off with the 2D parts (vectors, normals, distance, etc), then you can expand more if needed.

Thank you, I think I'll buy it.

I'm currently learning from Khan Academy, it's a really nice place to learn and I found it easier than I thought it would be.

Thank you guys. I'm going to share a few things I found as well:

Share on other sites

I found this one a useful reference for vectors, dot products etc

Share on other sites

Learn as much about maths as you can, I wouldn't underplay its important, particularly in the gaming world where most games will require a least decent knowledge (anything involving transitions requires integrated maths knowledge, although you can easily get away with only knowing a bit as you'll probably be using libraries and wrappers and stuff to hide away all the scary stuff).

The thing is that being a good mathematician teaches you process and rules, and programming being an applied science, those lessons are super important.

Logic and flow is key for anything involving telling a computer what to do and good maths knowledge will sow your logical seeds. It'll also teach you how to evaluate and assess problems. Maths is inherently a problem solving exercise and if you're serious about being a programmer then your whole life is solving problems, there are a few points to this: assessing a problem, understanding a problem, formulating a response, executing that response.

If someone asks you how long it will take you to do a new journey from point A to point B then you go through all those steps to arriving at an answer, almost everything you touch in programming is the same. In this trite example we'd probably strip back hard-to-measure stuff like traffic fluctuations and remove edge-cases like car failure or a broken leg and arrive at a solution that breaks down your journey into several small steps, estimates a time for all those steps, evaluates prior experience (i.e. I know this part of the route is always congested, or, I know I have to wait ten mins for a train) and eventually spits out a hypothesis that the journey takes 30 minutes.

If someone now asks you to solve a programming problem, i.e. my message pipeline becomes slow and unresponsive over time or how can I limit the number of active bullets in my shooter game and what number should that be, then you'll go through all those steps.

This is mathematical process.

So, whilst it is important to the learn the application of different mathematical disciplines (trigonometry, geometry, differentiation, computation etc), in truth, learning everything will help you and will give you a better grounding when you have hit a problem that falls mostly inside a specific discipline.

If you get any good at programming you'll be creating and manipulating algorithms, functions and pipelines all the time, this is the applied bit of maths and its arguably the hardest part. You'll be working with structures in your head, some will be complex so you'll need to be able to simplify and extract, you'll be using your logical skills constantly, you'll be testing and evaluating, you'll be postulating and formulating, you'll be creating (some) order from chaotic systems.

I wouldn't underplay the important of mathematical skills to any engineer/programmer.

I've seen too many decent programmers stall mid-career because their mathematical (particularly logical and assessment) skills aren't good enough.

Share on other sites

The above is very apt.

I've seen some of my old code where I had horrible math skills, compared to some of my new code there is a world of difference(where I'm still bad, but less horrible).   The difference was measured in pages, 20-30 pages compared to 12 for a missile command game(both were in Java and the 12 page one had a few more features like a menu screen.   They were coded about a decade apart just as an FYI).

Math will open some nice doors to short cuts/efficiency/sanity but it won't necessarily keep you from getting the job done.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.