What kind of Mathematics do Unity Employees use for this Engine?

Curious as to what kind of math these guys are using to develop this Engine?

And do they always know it off the top of their head or does it require them to go back to their text books?

What is it like quadratic equations and stuff?

Like, subtraction and addition.

Thats it? what about differentiation and logarithms etc?

2 Likes

wow that is a pretty nice link

The great part about Unity is that there is a robust math library included in the engine, so most common math functions, or mostly everything you need is there. However, even though you don’t have to understand the equations themselves, you do need to understand what they do or how they are used. So it’s probably a good idea to read a game math book so you are familiar with the concepts so you know which function to call or what kind of values you pass in or how to use what is returned.

However, if you are new to game development or game math, some of these textbooks may be really confusing at first. It may be easier to just start trying to program something and then, if you hit a wall, just search online for a solution as there is probably already sample code (many times in the Unity documentation itself) and you can solve the problem with little effort. Then, once you have something working, read the code and try to understand it. That seems to be the best way to learn.

Is this math needed for a metal slug 2D clone? this is what I am making

For 2D games it is much easier. You should have vector math fully understood (this is crucial for any game, but is the bread and butter for 2D). Trigonometry is also pretty important. Most of the physics and collision stuff is included, but you’ll still have to have some idea in order, for example, to get the player to jump exactly like you want or slide on an icy surface or things like that. But as I mentioned, these are things you can learn as you go, so just start trying to make the game and then do research when you need to figure something out.

To develop the engine is some pretty complex maths. Physics relies heavily on calculus. Rendering relies heavily on linear algebra. And don’t even get started on PRB and the lighting model.

However to use Unity you don’t need to get into much math. You need a solid grasp of vector math and basic algebra, but that’s it.

If you want to get into physics a basic understanding of Newtonian physics helps.

Linear algebra and calculus always help. Linear algebra is especially useful if you get into writing your own shaders.

But not much is needed just to get started.

1 Like

The engine uses standard run of the mill matrix and quaternion algebra that was known (in gamedev) since 1990s or 2000s.

Physics engine may use integrals and simplified integrals under the hood, but it is not guaranteed.

Game engines are mostly matrix multiplications, quaternion multiplications, addition, substractions, dot products and cross products.

Integrals and logarithms may pop up in rare situations, but are uncommon.

And that’s about it.

Addition, substraction, sin/cos/tan/atan, pythagores theorem, vector math in 2d space, maybe standard physics formulas for velocity and distance. Something like that.

1 Like

For a metal slug clone done with the least amount of experience, simply do everything with Unity Physics2D, it has it all: physics, movements, collisions etc. Be wasteful and just get it done - you may be positively surprised by the performance.

And the animations done with sprites. All of this is covered in Learn

5 Likes

quaternions give me a headache

4 Likes

The most difficult math I’ve had to do for any ‘everyday’ practical purpose in Unity was constructing and solving a polynomial to calculate an intercept solution for a weapon - which, well, isn’t really difficult? For semi-practical purposes the hardest thing was probably an erosion algorithm in a little terrain generator I made, or generating splines and things like finding shortest route to them etc - but it’s not something you’ll need for most things.

Unfortunately, the type of maths you run into in Unity will probably not be quite so elegant as e=mc^2, but rather monstrous, shaky piece-wise functions of relatively simple individual complexity which are much harder and less fun to deal with. For example, generating meshes for non-geometrical objects, procedural gameplay interactions, etc.

1 Like

This is very nice to know I shall definitely stick to 2D design

ooh very nice good to know

I think “coordinate geometry” were left alone in there, also the complex number. :smile: Nice resource indeed.

I think every math I encountered till my graduation, nearly all of them were valuable in game programming. I think so far the tough beast was “solving rendering equation” for spherical harmonics. Such a heavy math central thing :frowning: Also so far I do not fully understand quaternions yet. :(:frowning:

The problem with using Unity physics is that it is fire and forget, you can’t predict in advance the outcome.
Let’s say you want an object the end exactly in one position, I don’t think it’s possible with Physx.

“Non-deterministic” is the word you’re probably looking for here.

1 Like

Not what I was referring. Deterministic mean that If I apply X force I will end exactly at Y position.
What I meant instead is: what X force do I need to end up at Y position?
I am talking of predict an outcome.

Let’s say for example you have a grenade launcher. Can you calculate which direction and force use to hit an enemy using Physx? Consider a grenade will do an arc, not travel straight.

Yeah you would just need a projectile projection using gravity.
https://www.assetstore.unity3d.com/en/#!/content/55752