I have been trying and trying to get my character to attack and get damage dealt to him any ideas on what i’m doing wrong. here are my scripts.
attached to the enemy weapon
var Player : GameObject;
function OnControllerColliderHit(hit : ControllerColliderHit) {
if(hit.gameObject.name == "Player"){
gameObject.Find("Player").SendMessage("decreasehealth1");
}
}
attached to the player
var playerhealth = 100;
var myskin : GUISkin;
function decreasehealth1(){
playerhealth -= 5;
}
function decreasehealth2(){
playerhealth -= 7;
}
function decreasehealth3(){
playerhealth -= 10;
}
function OnGUI(){
GUI.skin = myskin;
if (playerhealth >= 100){
GUILayout.Box("", "fullhealth");
}
if (playerhealth >= 90){
GUILayout.Box("", "90%health");
}
if (playerhealth >= 80){
GUILayout.Box("", "80%health");
}
if (playerhealth >= 70){
GUILayout.Box("", "70%health");
}
if (playerhealth >= 60){
GUILayout.Box("", "60%health");
}
if (playerhealth >= 50){
GUILayout.Box("", "50%health");
}
if (playerhealth >= 40){
GUILayout.Box("", "40%health");
}
if (playerhealth >= 30){
GUILayout.Box("", "30%health");
}
if (playerhealth >= 20){
GUILayout.Box("", "20%health");
}
if (playerhealth >= 10){
GUILayout.Box("", "10%health");
}
if (playerhealth >= 0){
GUILayout.Box("", "0%health");
}
}
any help would be apreciated :}