I"m tryign to make a game that has a simliar leveling system to COD and BFBC2. In sort, if you don’t know, when a you use weapon X and “enemy” is killed, you get exp and the weapon X you used get a certina amount of exp.
Here is what I have attached to my " enemy":
var hitPoints = 100.0;
var deadReplacement : Transform;
var dieSound : AudioClip;
var deadbyplayer = false;
var dead = false;
var deadbyAI = false;
var flamehit = false;
var burntime = 5;
var hitbyplayerremington8 = false;
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "playerflame")
{
flamehit = true;
}
if(hit.gameObject.tag == "playerRemingtion8bullet")
{
hitbyplayerremington8 = true;
}
}
function ApplyDamage (damage : float) {
// We already have less than 0 hitpoints, maybe we got killed already?
if (hitPoints <= 0.0)
return;
hitPoints -= damage;
if (hitPoints <= 0.0)
{
playerscore.TeamAscore +=1;
dead = true;
}
if (hitPoints <= 0.0 && hitbyplayerremington8 == true)
{
MyFPS.CURRENTEXP +=1;
Playerprofile.CURRENTEXP +=1;
Playerprofile.KILLS +=1;
playerscore.TeamAscore +=1;
Remingtion8.FIELDPOINTS +=1
Playerprofile.Money +=5;
hitbyplayerremington8 = false;
deadbyplayer = true;
}
if (hitPoints <= 0.0 && flamehit == true)
{
MyFPS.CURRENTEXP +=1;
Playerprofile.CURRENTEXP +=1;
Playerprofile.KILLS +=1;
playerscore.TeamAscore +=1;
flamethrower.FIELDPOINTS +=1;
Playerprofile.Money +=5;
flamehit = false;
deadbyplayer = true;
}
}
static function CopyTransformsRecurse (src : Transform, dst : Transform) {
dst.position = src.position;
dst.rotation = src.rotation;
for (var child : Transform in dst) {
// Match the transform with the same name
var curSrc = src.Find(child.name);
if (curSrc)
CopyTransformsRecurse(curSrc, child);
}
}
function LateUpdate () {
if (deadbyplayer) {
hitPoints = 100.0;
transform.position = Vector3(16,6,-40);
deadbyplayer = false;
}
if(dead)
{
hitPoints = 100.0;
transform.position = Vector3(16,6,-40);
dead = false;
}
if(hitbyplayerremington8) {
WaitForSeconds(5);
hitbyplayerremington8 = false;
}
if(flamehit)
{
WaitForSeconds(burntime);
flamehit = false;
}
}
What did I do wrong? Any good resources to look at? Note: I do get the exp on the gun / player / other codes to work when I only have this
(hitPoints <= 0.0)
and jam all the other codes under it.