trying to access component from collision?
so i have a PlayerOwnsThisBullet witch on game start is set from1-5 i n order on the player that joins the room. PlayerOwnsThisBullet is on a bullet object that hits a Enemey unit to determan who hit it and who gets the score. for that hit,
using UnityEngine;
using System.Collections;
public class EnemyHp : MonoBehaviour {
public static float EnemeyHp = 5;
public static float Hitbyplayer = 0;
//------------------------------------------------------------------------------------------------------
void OnCollisionEnter (Collision Coll){
if (Coll.gameObject.tag == "PlayerBullet") {
Coll.GetComponent<Bullet> ().PlayerOwnsThisBullet;
Hitbyplayer = PlayerOwnsThisBullet;
// get this nuber to see what player attacked this unit.
EnemeyHp -= 1; // reduce health by 1.
if (Hitbyplayer = 1) {
Player1Score.Player1KillsLocal += 1;
}
if (Hitbyplayer = 2) {
Player2Score.Player2KillsLocal += 1;
}
if (Hitbyplayer = 3) {
Player3Score.Player3KillsLocal += 1;
}
if (Hitbyplayer = 4) {
Player4Score.Player4KillsLocal += 1;
}
if (Hitbyplayer = 5) {
Player5Score.Player5KillsLocal += 1;
}
Destroy (Coll.gameObject);
}
}
} // end collision check
//------------------------------------------------------------------------------------------------------