Right, I just went through the Lecture in 110, because, I really had no clue as to what he was asking and without a clue as to what this projectile thing he was was talking about and the beginning of the lecture. And I mean I HAD NO CLUE.
When I saw what he was talking about I said, yeah, I can add the collision detection without any hesitation. Right back to the video and then he proceeded to start talking about this Projectile class and this completely weird scripting about making a missile into a projectile and if it didn’t return a null value then it exits and then using that to make damage to the enemy.
And while I can see that it works - that is just something I would never do. Never - so that hint at the beginning was completely useless to me and realised it could be done in a matter that I thought was more straightforward.
So in the EnemyBehaviour script this is the script I used:
using UnityEngine;
using System.Collections;
public class EnemyBehaviour : MonoBehaviour {
public float enemyHealth;
// Use this for initialization
void Start () {
enemyHealth = 150;
}
// Update is called once per frame
void Update () {
}
/// <summary>
/// Raises the OnTriggerEnter2D Event
/// </summary>
/// <param name="col">Col.</param>
void OnTriggerEnter2D(Collider2D col){
//print ("Enemy has been hit by: " + col);
if (col.gameObject.tag == "myLaser")
{
print ("Definitely hit by laser :) ");
enemyHealth -= 100;
if(enemyHealth <=0)
{
print ("Health: " + enemyHealth);
Destroy(gameObject);
}
}
Destroy (col.gameObject);
}
}//end EnemyBehaviour
Now this seems to work and it makes complete sense to me! So I am trying to figure out whether to use the script as per the lecture which is completely foreign to me and let’s face I will forget how its done? Or, keep or using the method I do understand, can modify it as needed by the rest of the course?
Damn, these lectures where pretty straightforward and interesting until this lecture. Which has left me dazed and confused
. Excuse me while I kiss the sky.
Regards,
Vaughan.