5. Enemies and ammunition as a prefabs.
Ideally in the game I'm going to use three different types of enemies and two different types of ammo as a different prefabs. Prefabs are game objects combining all functions and preferences of particular object e.g. ''Prefab_Enemy1" (prefab of first enemy in the game) prefab will consist of c# script, sounds, animations, translate, rigidbody 2D and all components we attached to particular object. All prefabs are connected to their original object - they are clones. In order to create a prefab simply drag a game object that you created in the scene and drop it in project view. The name of this object will turn blue to show that is a prefab. Now we can rename our prefabs and delete blue objects in hierarchy view (note that if you're going to make any further changes to animations you will have to reverse above order - drag prefab from project view and drop it in hierarchy view apply changes and make the prefab again).
All enemies are using the same algorithm representing their artificial intelligence. Basically enemy ray-casting against player, if player is in the range then enemy starts walking towards player. Each collision between the player and enemies decreases player's life. To detect collisions between different enemies I used tags, so each enemy has unique name and can deal different damage.
Three types of enemies:
No comments:
Post a Comment