


Are cubes the best way to visualize graphs? Remove its BoxCollider component, as we won't use physics. We'll simply use Unity's default cube game object for this. To do this, we need a 3D visualization of a point. Graphs are created by placing points at the appropriate coordinates. We'll start with a new project, as described in the first section of the previous tutorial. It's a handy tool, so let's create one in Unity. Looking at a graph can quickly give us an idea of how a function behaves. Graph with `x` between −2 and 2, made with Desmos. If we use enough points that are very close together we end up with a line. This is a 2D vector where the top number represents the horizontal coordinate, on the X axis, and the bottom number represents the vertical coordinate, on the Y axis. Instead, we could interpret the pairs as two-dimensional coordinates of the form `,]`. That will end up as a sea of numbers, which are hard to parse. We're going to need many points, close together. We could write down a few input-output pairs, but that likely won't give us a good grasp of the mapping it represents. The function `f(x)=x+1` is easy to understand. But it is easier to understand the function when we order the pairs by the input number.

We can create many pairs of the form `(x,f(x))`, for example (5,6) and (8,9) and (1,2) and (6,7). A shorter way to write this would be as an input-output pair, like (3,4). We can say that the function maps 3 to 4. We provided 3 as an input argument and ended up with 4 as the output. We can substitute a number for its `x` parameter, say 3. The rules of mathematics dictate how this rewriting can be done.įor example, we have the function `f(x)=x+1`. Solving an equation boils down to rewriting one set of symbols so it becomes another-usually shorter-set of symbols. At its most fundamental level math is the manipulation of symbols that represent numbers. Creating a Line of CubesĪ good understanding of mathematics is essential when programming. This tutorial is made with Unity 2020.3.6f1. We'll also make the function time-dependent, creating an animating graph. This time we'll use game objects to build a graph, so we can show mathematical formulas.
UNITY 3D TUTORIAL SERIES
This is the second tutorial in a series about learning the basics of working with Unity.
