Saturday, May 14, 2016
UI (Having Problems)
For some reason im having problems with the UI. Whenever I finish the whole UI, save file, exit out of the file, and come back into the file, only half of my UI shows and not rest of the work I did with UI. I will keep working on it and hopefully I can fix this problem.
Thursday, May 12, 2016
Tuesday, May 3, 2016
EnemyHealth Script
using UnityEngine;
public class EnemyHealth : MonoBehaviour
{
public
int startingHealth = 100; // The
amount of health the enemy starts the game with.
public
int currentHealth; // The
current health the enemy has.
//public float sinkSpeed
= 2.5f;
public
int scoreValue = 10; // The
amount added to the player's score when the enemy dies.
//public AudioClip
deathClip;
Animator
m_animator; //
Reference to the animator.
//AudioSource
m_enemyAudio;
ParticleSystem
m_hitParticles; // Reference to
the particle system that plays when the enemy is damaged.
CapsuleCollider
m_capsuleCollider; // Reference to
the capsule collider.
bool
isDead; //
Whether the enemy is dead.
//bool isSinking;
void Awake ()
{
//
Setting up the references.
m_animator =
GetComponent <Animator> ();
m_hitParticles
= GetComponentInChildren <ParticleSystem> ();
m_capsuleCollider = GetComponent <CapsuleCollider> ();
//
Setting the current health when the enemy first spawns
currentHealth
= startingHealth;
}
public void
TakeDamage (int amount, Vector3 hitPoint)
{
//
If the enemy is dead...
if(isDead)
//
... no need to take damage so exit the function.
return;
//m_enemyAudio.Play
();
//
Reduce the current health by the amount of damage sustained.
currentHealth
-= amount;
//
Set the position of the particle system to where the hit was sustained.
m_hitParticles.transform.position
= hitPoint;
//
And play the particles.
m_hitParticles.Play();
//
If the current health is less than or equal to zero...
if(currentHealth
<= 0)
{
//
... the enemy is dead.
Death
();
}
}
void Death ()
{
//
... the enemy is dead.
isDead
= true;
//
Turn the collider into a trigger so shots can pass through it.
m_capsuleCollider.isTrigger
= true;
//
Tell the animator that the enemy is dead.
m_animator.SetTrigger
("Dead");
//m_enemyAudio.clip
= deathClip;
//m_enemyAudio.Play ();
ScoreManager.score
+= scoreValue;
}
}
Subscribe to:
Posts (Atom)