Gamespace: Enemies

I wanted to create an enemy that when the player collides with the object points are deducted from the health bar. I also wanted my enemy to fit with the theme and therefore made it look like a raincloud.


Raincloud enemy with added box collider


Raincloud enemy deducting points from the health bar


This is the inspector for the raincloud enemy. 
The 'Enemy' script is attached and a box collider component is added so that when the player collides with the enemy the script understands that a collision has occurred.


Cloud Enemy Inspector


The Enemy script works by using an 'OnTriggerEnter' function. Therefore, when the player collides with the box collider that encapsulates the rain and rain cloud this function is called.

The variable 'healthBar' is received. 
If the value assigned to the health bar is not equal to nothing, then the health bar takes 10 damage when the player collides with a raincloud.



Enemy Script


To make my raincloud enemy more realistic, I added a particle system so it appeared that the cloud was raining.

The play on awake and looping options were checked as I wanted this particle system to be a continuous stream of particles to resemble rain.



Particle system for raincloud rain

The emission and shape values were tweaked slightly but mostly stayed the same.


Emission & shape for the particle system

The collision was switched on so that if the rain particles collided with the ground, they wouldn't just fall through it. 
Therefore the Type was set to 'World'.


Collision in the particle system

The renderer option allowed me to change the colour of the particles, which I did so that they looked more like rain.


Renderer in the particle system

Comments

Popular posts from this blog

Unity Project 4: Ball platformer game

[Research] Traditional Poster Design (4CTA1214)