2. Ball Camera Mode - once the user interacts with the Drop Button, the Player Camera Mode and the Tube Camera Mode will both be disabled and the Ball
4.3.9 Objects Collision Checking
Components of the Gravitron Virtual Exhibit such as the Ball object, Floor object and the Wall objects already have a Mesh Collider checkbox that determines whether it is a solid type of material that will not pass through other objects (like the player object).
This allows the user to walk on the Floor object without falling through. Components that are created outside of the Unity software, such as in Blender, require a bit more work to achieve the same result. By default, the objects will be just images displayed on the screen. To add the Mesh Collider component to each object created outside of Unity or any objects that do not have it (but require it for collision checking), there is a button in the Inspector window that allows the additional components (as shown in the picture
Note that there are different types of colliders, the section below will discuss the ones that we will use in the Gravitron Virtual Exhibit along with the advantages and disadvantages of each one.
Mesh Collider
The Mesh Collider provides a collider around an object based on its mesh, thus allowing more precise collision checking on an object if the object is a complex shape.
The advantages of having a mesh collider on an object:
● No need to adjust to the alignment of the object since this option covers each aspect of the object.
● Ensures a very smooth and precise reaction to collisions from other objects.
● Easy to determine where the collision occurs.
The disadvantages of having a mesh collider on an object:
● Extremely expensive to implement, in term of computations required, if the object is complex.
● Cannot have more than one mesh collider per object, thus limited to one.
Sphere Collider
A primitive collider that provides sphere objects to detect collisions much more efficiently, thus this is the best option for spherical objects such as the Ball object. This collider will not work well with objects that are not rounded.
Box Collider
A primitive collider as well that provides a 3 dimensional cube shape that can be shaped into a flattened cube or rectangular prism. It is also scaleable.
The advantages of having a box collider on an object:
● Cheaper to implement on an object, in terms of computations required.
● For complex shapes, you can have more than one box collider on an object to achieve a similar collision checking and reaction. To do so, each object can only have one type of collider on at a time, create a child object of the current object and add another box collider to that one; to add more box colliders, create another child of the same object. Unity will treat all the box colliders in the child objects as the same collision check with the parent object.
● Easy to utilize
The disadvantages of having a box collider on an object:
● For complex shapes, can also be difficult to implement. Having too many box colliders on an object can cause some confusion.
● Requires more manual manipulation of the collider than the mesh collider option.
● Have to be as precise as possible for the correct physics response, otherwise the collisions with other objects will not have the same result as in real world physics.
Collision Checking (Ball Object)
As discussed earlier, the Ball object is just a sphere created in Unity, thus the best option is to have the sphere collider component on it. The picture below will represent the sphere collider outlined onto the Ball object, each line will be able to detect collisions from any objects interacting with the Ball object:
Collision Checking (Tube Objects)
Since the Tube objects can only move and rotate in the x-y plane, it only makes sense that the best option would be to have the box collider component on instead of the mesh collider. But to show the difference between the mesh collider and the box collider, the picture below will explain the reason as to why the mesh collider is much more expensive and the box collider is the better alternative:
(Picture above) - Notice how the outlines are covering the entire mesh of the object, thus providing very precise collision checking but it also requires a lot more computation.
Now to compare the mesh collider with the box collider component on the same Tube object:
The box collider covers the whole Tube object in a rectangular prism. However, we only need the collision checking to be at the bottom surface of the Tube object rather than the whole object else the Ball object will roll on top of the open Tube (which would be very awkward). Unity allows us to adjust the box collider accordingly as shown in the picture below:
This method will be sufficient enough for the purpose of the Tube objects. And if there are scenarios that requires the system to check for the Ball object if it collides on the top portion of the Tube object, then we can simply create a new empty game object and set it as the child of the collided Tube object (parent) and add another box collider to that child object, in which case, Unity would then count those two (child and parent) as a