Thursday 4 May 2017

Outside the Box Project Beta Work - Polishing Enemy Movement Across the Board

Like how Tags can be used in code to control interactions between mechanics in games, all models have Layers set to a "Default" Layer which can control Physics interactions.

One of the problems that made our game appear a bit jank (un professional) was that our Enemies would "bounce" and freak out on the spot as they moved between waypoints. The problem was that the Layers of all 3D models in Unity are automatically set to "Default" and that meant the base of the models of the Enemies were interacting with the Ground model.

So to fix this I created a brand new Layer in the same way one would create a new Tag entitled "Enemy"and set the Enemy Prefab's Layer to "Enemy" (as seen in Figure's 1. and 2.).

Figure 1.

Figure 2.

Then one would go Edit > Project Settings > Physics. And because there is a newly created Layer, there are new tick boxes in the Physics Project Settings. By un-ticking Layer boxes that intersect, all models with the 2 appropriate Layers attached to them will no longer interact with each other in the scene. So by un-ticking the box that intersects between the "Enemy" Layer and the "Default" Layer, our enemies are no longer interacting with the Ground model, which has the "Default" Layer attached (as can be seen in Figure 3.).

I used this method to prevent some issues with the Bullets as well. As they would collide with the Defence models in the scene if the Defence model was in the way of the Bullet reaching the Enemies, and would fly off the screen, rather than colliding and causing damage like they should. 

So I also created a new Layer for the Bullets, like with the Enemies, and un-ticked the intersecting box with the Defences to prevent the Bullet's and Defence interacting with each other, which in turn prevented the Bullet's from flying off screen; something they have no reason to do in the context of the game.

Figure 3.

No comments:

Post a Comment