Day 24 – [SinC] – Chess look, Bug DontGoThroughThings, Trigger and rayCast.
Mirrored from my blog (en, pt-br).
Today I started making a change in the look of sync, as I want to focus on the mechanics at the time I did everything a chess texture. I was pleased, because became standardized and acceptable.
Then I started to build a level of one of the possible modes of play. The goal will be to put cubes of each color to its respective place (call stand) with the shortest time possible. The count will be progressive with precision of hundredths of seconds.
Here comes one of the main mechanics of the game, stop time.If the player press Shift the time stops, “Freezing” all the movements of the cubes and projectiles in the scene. When the player shoot with the time stopped the projectile will be stopped and will come be to its trajectory when the time starts flowing again.
Using the stop time the player will be able to better analyze and give shots synchronized, which will make, strategy and calculation of the force of the projectile (mass x speed), be a major factor in the total time of the level. When a cube is thrown out the level time will be added to the total time as a penalty.
In this video you can see how this game mode is. (In the video doesn’t have the time yet).
Doing the logic of game winning I found two bugs that was difficult to resolve.
The first was more a lack of my attention. After putting a Trigger in the level the cubes began to move in strange ways (video below).
At the end had nothing to do with the Trigger. What happened is that sometime before I added the DontGoThroughThings in the cube for it not pass the walls of the stand, but I ended up using the same layer that the cube is (In the script DontGoThroughThings the object using the script cannot be in the same layer that it will check the collisions). And as I was only testing after I added the Trigger I was thinking that the problem was with it, it was difficult to find the real problem.
To resolve this, as an object cannot have two layers, I had to use a workaround I found on the internet. Duplicated the object, removed the Mesh Renderer and placed as a son of the duplicate. Put a different layer in the duplicate. I didn’t like this solution, but for prototype work, so I’ll leave to search for a better solution later on.
The second bug, which was easier, but it also took a while was that at certain points the gun was becoming unaligned with the projectile, it happened because of some Triggers that was inside of the stand and took them rayCast. To solve this just use layerMask and pass as argument in the rayCast that it ignores this layer. But I’ll leave it to do tomorrow.
PS: Sorry for the bad english.