deflection meters are one of the more useful parts of a game’s physics engine.
With these, you can take a snapshot of your game’s geometry and use it to tweak the game’s behavior to make it a little less responsive.
This can also be used to simulate more realistic physics effects.
If you want to see how a game uses these meters, check out this article from Game Developers Choice.
In this article, I’ll walk you through how to create a simple deflection meter in Unity3D.
This is only a starting point, but it’s a good start.
You’ll want to set up your meter using the following steps: The first thing you’ll need to do is set up the default position of the meter.
For our example, we’ll use the leftmost position of our meter.
Select the left-most position in the meter, and press the [Move] key.
This will move the meter a little to the left.
You can now position the meter anywhere in the scene.
Next, create a new physics object in the inspector.
We’ll use a few different physics objects in this tutorial.
Select a new object in your inspector and press [New].
Select a physics object and press ‘Create Physics’ to create the new object.
This should create a physics collision mesh.
Click [OK] to close the inspector window.
We can now use the [Mesh] button to set the geometry of the object.
In the inspector, press [Mesh].
We can also change the material properties of the mesh.
In our case, we’ve set the Material to be transparent, but the default material for our meter will be white.
In [Mesh], select a new mesh and press OK.
You should see the new mesh in the Inspector.
Select [Create Mesh] again and choose the mesh from the drop-down menu.
Finally, select [Mesh Collision] to create our collision mesh, then press [OK].
You should now have two objects in your scene.
Now we can create our deflection unit in the physics inspector.
In Unity, we can use the Physics Toolbox to drag the meter around in the game.
In your editor, press the Cmd + [Left] and [Right] keys.
You will see a list of Physics Objects that you can drag and drop in the Unity Editor.
If we drag our meter, we should see our meter move in a clockwise direction.
This would be the direction our meter would be moving.
Next we need to define our angle of the deflection in the collision mesh as a number between 0 and 360 degrees.
The [Scale] and the [Collide] buttons in the Physics Editor should give you the options for the angles we need.
For now, we’re just going to use a value of 0.0.
Let’s say we want to add a 1-degree deflection to our meter in the middle of the scene, so that it moves up and down at about 30 degrees per second.
In fact, that’s what our meter is currently doing.
Select this option, and then press OK to create your collision mesh and move it.
Notice that this collision mesh will only have 1 collision.
Now that our meter has its deflection set up, let’s create a collision in our geometry.
Select your collision in the [CMD] menu and press and hold [Control].
You’ll see a collision mesh that looks like this.
Click the [OK]” to close Unity’s editor.
We should now see our collision in Unity.
Now, we need a way to update our meter position to be updated.
Selecting the [Update] button will update the meter’s position.
Notice we’ve moved our meter around.
Now let’s add some more movement to our deflections.
Select our meter again and press in the left corner of the editor.
Now our meter should be pointing in a straight line.
Press [Change] in the right corner of Unity’s Editor.
We now have our deflected meter in our collision.
We’re going to set our defraction to 1, and our offset to zero.
We need to set this value in our mesh to make the deflections correspond to the position of each meter.
This could be a good place to set a value like 100, but this is the minimum we should expect.
In order to change the position, we have to go back in the editor and change our position in that mesh to match the offset we gave.
In a new window, go to the [Shape] menu, and select [Deflect].
Now we should have our meter’s deflection move in the direction we set.
Let us set it to go up and to the right.
Go to the editor again and set the defraction value to zero, and set your offset to 360 degrees: Now, in the same window, change the shape of our collision to reflect the direction of the original deflection: That’s it!
Our deflections now match the deflected position