string
Even we tried to use the comparison through the the boolean or integer, the situation of using string comes pretty often. I though the processing times of comparision regareded one of important thing when writing codes. Among them, I tend to use faster method via boolean and integer to avoid the wasted time. However, even though the comparision with string type is slower than the boolean, we can improve the performances by converting hashcode.
Facilitating hashcode give lots of benefits not only the processing time, but also the security. Before to study the hashcode in unity, I tried to understand the operation with the following codeblock.
string str = "Hello, World!";
if(str.Contains("Hello"))
{
str.Replace("Hello","Bye");
}
The method of Contains
puts boolean which means the existance ot parameter in the string. Similarly, the Dictionary<string, bool>
can give the boolean value depending on key string
. The difference comes from the conversion of string to hashcode. the function Contains
could not be faster than the dictionary due to the method of string doesn't contain the conversion(string.cs, Line: 2172).
The way to make collision area in Unity has various option. The lecture contains only the usage of BoxCollider
at the projectile sprites. Even though the basic shape is prefered for the repeated object, I want to learned the complex shape. One of the method is the union, the combination of small pieces of shape. In Unity, there are union method named as Composite Collider
. When you make basis like Box collider
, there are an option named as Used by Composite
. If you check the box, the composition process will occur.
Finally, you can see the tidy shape than previous one. This method can pretend the situation of stuck between the collider.
You can see the overlapped area on the upper figure.