Ok I admit most of us hate Maths, and you will be tempted to skip this article but I recommend sticking out till the end hopefully it will be worthwhile.

Maths is a necessity for Game Development so knowing the basic stuff to be able to use it in practice is something game developers must know about. This helps in all fields of Game Development.

So let’s get started.

The most basic mathematical function(in my opinion) would be

y = x or f(x) = x

Here we see that function ‘f’ applied on x gives 'x’. So what does this mean? This gives us enough information to create a graph.

Nice so a function represents a line. Now What?

Well in reality functions don’t just represent a line but 2D coordinates which enable us to create the lines or curves or ellipses. So for this lesson we will be delving into 2D graphs only.

Let’s take a look at another function.

f(x) = x2/10

In this case function f applied on x gives an expression. That gives values that make up a curve.

Ok so I learned Maths end of lesson.? Well not so much now we will apply it in a real example.

So let’s first create an equation to use.

f(x) = sin(x)

Let’s open up Godot and try to apply this equation.

I have made the shader a little red so it’s easy to see which part of the image it affects.



So I created a basic screen-shader(add the shader material to a color rect and set it the screen size and use SCREEN_TEXTURE and SCREEN_UV),

and applied the equation as a multiplier to the SCREEN_UV, all this effect does is using the X value changes the offset of the UV’s making them curve like a sin curve. Let’s see a better example.



Here I only use the sin() to change the Y value of the UV.

What this does is change the Y value to and fro from -1 to 1.



Although according to maths in the range of 0 to pie(which is the effective range here) we only see 0 to 1 and then back to 0.

So what now, that means when the value will be negative it won’t be visible as negative UV.y is not possible. Let’s try it out.

So when the value goes below 0 it’s not visible. Cool.

Let’s use the absolute function now, it changes the value of to a positive value if the value is negative and thus we only get values from 0 to 1.

So abs(sin(x)) or |sin(x)| is,

So what will it look like in GODOT,

So that’s it, no not really let’s add another fun little animation.

It’s not upto scale so your animation speed will differ.





TIME keyword gives the time value which keeps changing continously.



So now’s time for some awesome home-work,

Try creating this,