Seriously, I have tried everything! My dilemma is that I am within a outreach of completing my first game. It seriously can be finished within the next week or two. But there is this certain code (actually two codes but the first one is making me furious) that won’t do want I want it to do. I basically have this code where I want to have a projectile collide with the enemy I have programmed but under any circumstance, the two just will not collide with each other. They both have a collider set upon them, both the same, and the two just won’t collide with each other. I have went through tutorial after tutorial, even to the scripting reference, to figure out this problem but no luck. Here’s the code for the enemy:
#pragma strict
var Miner : GameObject;
var currentHealth : float = 0.0f;
var maximumHealth : float = 20.0f;
function Start () {
currentHealth = maximumHealth;
collider.enabled = true;
collider.material.dynamicFriction = 1;
}
function OnCollisionStay (col : Collision){
if(col.gameObject.name == "telekinesisball(Clone)")
{
Destroy(gameObject);
}
}
function ApplyDamage (projectiledamage : float) {
currentHealth -= projectiledamage;
if(currentHealth <= 0){
Destroy(Miner);
}
}
And here’s the one for the projectile moving:
#pragma strict
var object : GameObject;
var speed = 20.0;
var time = 0.0;
function Start () {
collider.enabled = true;
collider.material.dynamicFriction = 1;
}
function Update () {
time += Time.deltaTime;
transform.Translate(Vector3.forward * speed * Time.deltaTime, Space.Self);
if(time > 5)
{
Destroy(gameObject);
}
}
function OnCollisionEnter (projectileCollision : Collision)
{
Destroy(object);
}
I probably am missing an important step but it probably flew over my head so some help would be obliged. Please, I am in the final stages of this game and I need this to work. Please help me! thank you.