Search Unity

Math Necessary?

Discussion in 'General Discussion' started by JamesDuBois, Aug 11, 2016.

  1. JamesDuBois

    JamesDuBois

    Joined:
    Apr 7, 2016
    Posts:
    13
    Hey guys,

    I want a stronger math background though for game programming. What math is necessary to do some really cool math based games. I know some companies make you solve a calculus problem in the interview process and if you cant do it, then you mine as well just leave the room. I have a decent handle on trig, as I just finished a class on it in school but I want to expand my knowledge more. I am taking pre-calc/calculus 1 next semester.

    https://www1.apply2jobs.com/Insomni...tion=mExternal.showJob&RID=1150&CurrentPage=1

    On that job posting is says 3D math, so do I need to dig into Matrices etc?
     
  2. MathiasDG

    MathiasDG

    Joined:
    Jul 1, 2014
    Posts:
    114
    Well, most game math uses matrices and vectors. Myself i use a lot of geometry math, which includes both matrices and vectors.
     
    angrypenguin and hippocoder like this.
  3. wccrawford

    wccrawford

    Joined:
    Sep 30, 2011
    Posts:
    2,039
    While many games do require math, many companies use math in the interview as a way to weed out people who can't do logic well. Most actual games have very little math, and if you actually *do* any calculus in a game, you're doing something really bleeding edge or some work on the internals of an engine.

    Most math is already going to be abstracted away for you, like Quaternions. There's no real need to know what a quaternion works, you just need to know how to use the functions that make use of them. (And how not to screw them up.)
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I made up my own maths that work for me. If you're indie - do whatever works. If you're applying for jobs as a programmer, you will need good maths, I can't imagine an employer wanting otherwise...

    Insomniac explicitly ask for:

    So you need to know quaternions, how to use them, multiply them and why, all vector maths, dot, cross, etc. Normals. Spatial stuff. Matrices. Sounds like it's well past you already if you had to ask.

    Basically - know how to make a small working 3D engine, and understand it. Be able to make a simple boxy level, render it correctly. This should give you what you need to know... it doesn't need to look good but it needs to work and be understood.
     
  5. grimunk

    grimunk

    Joined:
    Oct 3, 2014
    Posts:
    278
    Math is definitely a requirement if you want to be a gameplay programmer. Definitely learn basic linear algebra. In particular, I would spend a fair bit of time learning Quaternions. You can find a fair number of videos that explain the concept well.

     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
  7. I_Am_DreReid

    I_Am_DreReid

    Joined:
    Dec 13, 2015
    Posts:
    361
    I know basic high school math and that works good for me, although if i stumble upon something out of my comfort area i will buzz dr google for an answer
     
  8. Le_Tai

    Le_Tai

    Joined:
    Jun 20, 2014
    Posts:
    442
    What calculus have to do with game dev?
     
  9. soufianetafersite

    soufianetafersite

    Joined:
    Jul 24, 2016
    Posts:
    9
    Mostly vector math.
     
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Calculus is fundamental to physics. Physics is kind of important to game dev. Calculus is also an incredibly important tool in mathematical modelling. Modelling is useful in all sorts of areas.

    You don't have to use calculus to make games. But it is a useful tool to have.
     
  11. anngrant

    anngrant

    Joined:
    Aug 15, 2016
    Posts:
    14
    Math is everything here, dude
     
    angrypenguin likes this.
  12. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    I honestly think we honestly eventually end up doing some math we never thought we could do without ever even realizing it haha. All because it's done in a different context, we don't even realize we ended up doing some Astrophysics lol.

    Point I'm trying to make, Math is everything, and it may seem hard on a Math Book, but chances are you will or have done some fairly complicated math that you never thought you could do without even realizing you've done it.
     
  13. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,971
    Every bit of math you know expands what you can do. You don't have to be an expert who remembers all the formulas by heart. But knowing what to look for makes all the difference, it's good to know what the heck to type in the google search bar in order to get the answer you want. If you don't even know a certain subject exist, you don't even know there's an actual solution for your problem out there.
     
    Last edited: Aug 15, 2016
    angrypenguin, Kiwasi and LeftyRighty like this.
  14. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Trigonometry is extremely helpful. The engines abstract most of that away for you but if you want to get into writing things that require heavy calculations, at least basic trig is really helpful.
     
    Kiwasi likes this.
  15. Mwsc

    Mwsc

    Joined:
    Aug 26, 2012
    Posts:
    189
    Years ago, game development used to be tied with engine development, because general-purpose engines like Unity didn't exist. Back then, being a game developer meant knowing how to write a very fast 3D renderer, as well as the physics. If you are content to use somebody else's code for that, you could get pretty far just coding the logic for how characters respond to user input, react to each other, etc, without much math.

    This is why you see people saying "you don't need much math unless you are doing engine internals".
    If you want to write a fluid simulator, you need math. If you want to write a shader, you need math.
     
    wccrawford and Kiwasi like this.
  16. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Here's a good example of where you might need a little heavier math and in what scenario. Let's say you want to do 2D collision detection but not with circles or squares (or rectangles). You may have Hexagons, Octagons, or some weird arbitrary convex shape. This is a perfect job for the Separating Axis Theorem. Unity handles most (if not all) of these calculations for you with extensions off of the various Vector classes, but it wouldn't be bad to understand them yourself.

    What's cool about the SAT is that it's a fun learning exercise. Back when I was using XNA which was only a framework without a fancy editor and as many extensions, I set ought to build a terrain system. I wanted dynamic LOD and I wanted View Frustum Culling. The LOD bit was pretty easy, the culling wasn't as difficult by default but didn't have great performance. Since the view frustum is essentially a lopped off pyramid and my terrain was quad-tree based with bounding rectangles, the intersect tests between the Frustum and Bounding Rectangles was very expensive. It was intersects between 3D volumes.

    Instead, I decided I didn't care about height for what I was doing and I used math to determine all of the points at which the view frustum intersected the plane at the 0 y-axis position. Now, taking near and far clipping planes into account, this meant that the entire frustum could be above the ground plane... or below. Or the far two bottom points could be blow the plane, or all 4 far clipping points could be below the terrain. Then there's the issue of camera tilt (is it rotated?). So, given these considerations you could have anywhere from 1 to 7 points below the terrain with the terrain still being visible.

    Using this information I was able to figure out where the corners of the frustum intersected the plane, and these points became a 2D shape on y = 0. Then, rather than using bounding boxes, I used bounding rectangles. With the frustum shape and the bounding rectangles, I was able to use the separating axis theorem to rapidly detect whether there was an intersect between the frustum and the rectangles. SAT is also a very efficient algorithm because it's self-pruning. If it finds one set of lines that intersect it can return a positive result and not have to check for every possible set.

    Here's a good article on SAT with example code:
    http://gamedevelopment.tutsplus.com...sing-the-separating-axis-theorem--gamedev-169

    And here is my blog article that talks about clipping with 2D Shapes. There's one section that I think can be cleaned up a lot... and that's the block that tests how the Frustum intersects the ground plane... it's a whole series of nested ifs, and it was written in one go so you can kind of ignore it. :) But the rest is pretty good:

    http://www.dustinhorne.com/post/2011/10/18/XNA-Terrain-with-LOD-Part-7-Better-Culling-With-2D-Shapes
     
  17. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,363
    Depends on how "mathy" your game will be. You can make noughts and crosses with very little math, just a knowledge of 2d coordinates and common sense. Making a game like Minecraft would need a lot, although its simplified a bit with everything being blocky. An A-level in maths would be useful. Or you can just look at stuff online and learn through YouTube.

    IMO there are two types of games, the arty character based games that are all about the story and artwork and then there are the algorithmic type of games like minecraft which is all about the amazing things you can do with maths and clever optimisations.

    If you hate maths go for the former type of game and make a great story with great characters and music.

    (And if you hate art go for the second type!)
     
    dogzerx2 likes this.
  18. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    To wit, this community has determined that learning C/C++ to build a foundation for C#, which builds upon C/C++ is quackery, but that calculus is fundamental in game development in Unity, which uses a robust, automatic physics engine. Carry on.
     
  19. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    you still end up using a lot of vector math, linear algebra and trig in game dev. Not to mention the problem solving skills that come with a math background.

    Also if peoples intent is c# why would you start on c++ that is just stupid.
     
    Last edited: Aug 16, 2016
  20. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    Okay, champ.
     
  21. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    https://en.wikipedia.org/wiki/Calculus

    Speed is a derivative of position.
    Acceleration is a derivative of speed or double-derivative of position.
    Calculating new position of a moving object means integrals.
    Physical forces such as air drag result in differential equations.

    ---------

    Also, those articles may be interesting:
    http://chrishecker.com/Rigid_body_dynamics
     
    Kiwasi likes this.
  22. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Nah, this community (and the Internet in general) can't decide on such things, but sometimes only one side of the debate shows up to say anything. ;)

    I happen to think that both learning C/C++ is exceptionally handy for understanding how a computer works, and that that understanding is exceptionally useful for game development regardless of the language you're using at the time. Do you have to learn it? No. Is it helpful? Absolutely.

    For maths, as others have said, you can get away with just using what's provided in the existing libraries and kludging the rest as you go. But having a reasonable foundation in math is super handy so that you can figure out new stuff for yourself. As has been mentioned, this often involves knowing what to search for.

    It's not all about equations, though. Just as important is understanding the relationships between the various numbers along the way. If you don't understand this then everything is going to be "black magic" and you'll never be able to solve new problems for yourself.

    The good news is this: it's actually not that hard to learn if you take it one step at a time! If you're like me that sounds hard to believe at first, because high school math is a pain. I sucked at it. It turned out later that I mostly sucked at it because it was all so abstract - the advanced topics were never tied back to real world, tangible results. When learning in the context of software or video games that's never the case, though - you always do math because you're directly using the result to solve a problem.

    And if you break down that problem and understand the solution one step at a time then the math is usually pretty straightforward. There are often loads of numbers, and they often get run through many steps. Thankfully the computer is awesome at doing that for us, so we just need to understand each step and tell the computer how to do it. It's a very different experience to the one I (and probably many others) had in high school learning math, because results are meaningful, we're always directly solving a real-world problem that puts the numbers and their relationships in perspective, and it's never about passing an arbitrary test.

    So if you're asking about math because you hope to avoid it, don't. At best you're making life harder for yourself, at worst you're limiting your capability. Don't let a prior bad experience trick you into doing that to yourself.

    (Edited for clarity.)
     
    Last edited: Aug 16, 2016
  23. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    Still the best. Better than all the rest. A gentleman and a scholar.
     
  24. Le_Tai

    Le_Tai

    Joined:
    Jun 20, 2014
    Posts:
    442
    Wow when they taught me calculus in highschool I never being told what it actually use for. Now I finally know
     
  25. Deon-Cadme

    Deon-Cadme

    Joined:
    Sep 10, 2013
    Posts:
    288
    Yes, many game companies give you a math test as a part of the interview and you have to solve it within a limited amount of time. If you have to solve everything is a completely different question, a few companies even give you an impossible test just to see how much you solve and how you handle the situation etc...

    The kind of math that you need is completely different depending on the position that you are applying for. A physics programmer obviously needs to be a math expert with a deep understanding of physics and more... concept artist will not even be asked about his math skills while a 3D artist might be asked to prove that he have enough knowledge to throw together a shader that do "this or that".
     
  26. computertech

    computertech

    Joined:
    Feb 17, 2015
    Posts:
    208
    In my google drive there is many math, calculus vectors, statics data management notes. They are mostly grade 12 university high school levels.

    Math Notes=
    https://drive.google.com/folderview...s4UHJYbnJpcHVCa0R3TTBxVWo4TlRMRGs&usp=sharing

    Calculus Vectors Notes=
    https://drive.google.com/folderview?id=0B2YJGvS8qreYLXBTTGh2QlQxbGs&usp=sharing

    Statics Data Management Notes=
    https://drive.google.com/folderview?id=0B2YJGvS8qreYS2E2Nk9rOVpleDQ&usp=sharing

    I think you will also need to know physics as well.
    Physics Notes=
    https://drive.google.com/folderview?id=0B2YJGvS8qreYeXhnTjhBYTJ4OE0&usp=sharing

    The best notes of all time should be in this link...
    https://www.studyblue.com/
     
    Last edited: Aug 18, 2016