- Home /
Question by
Trizza_Greenwood · Jun 02, 2013 at 12:59 AM ·
scorepoints
[need help please] Score when AI Dies
My Score Script ---
private var CurScore : int = 0;
function OnGUI () {
//Score Streak title.
GUI.Label (Rect (10,450,160,40), "SCORE / " + CurScore);
}
function ApplyScore ( ScorePoints : float ) {
CurScore ++;
CurScore = ScorePoints;
}
My AI Script -------
var distance;
var targetplayer1 : Transform;
var lookAtDistance = 100;
var attackRange = 100;
var moveSpeed = 5.0;
var damping = 6.0;
private var isItAttacking = false;
var Health : float = 100;
var MaxHealth : int = 100;
var CurHealth : int;
var BadGuy : GameObject;
var DealDamage = "";
var SpawnPosition : Transform;
var ScoreScript : ScoreStreak;
var ScorePoints = 60;
function Update ()
{
distance = Vector3.Distance(targetplayer1.position, transform.position);
if(distance < lookAtDistance)
{
isItAttacking = false;
lookAt ();
}
if(distance < attackRange)
{
attack ();
}
}
function lookAt ()
{
var rotation = Quaternion.LookRotation(targetplayer1.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
}
function attack ()
{
isItAttacking = true;
transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime);
}
function Start () {
CurHealth = MaxHealth;
}
function ApplyDamage ( Damage : float ) {
if(CurHealth < 0){
return;
}
CurHealth -= Damage;
if(CurHealth == 0){
SendMessageUpwards("ApplyScore" , ScorePoints, SendMessageOptions.DontRequireReceiver);
Destroy( BadGuy );
}
}
Comment
It doesent seem to change the score from 0 :( help?
CurScore ++;
has no effect if after it you assign a value to this variable.
Your answer
Follow this Question
Related Questions
Points when an enemy dies. 2 Answers
Problem with duplicated score! 1 Answer
Scores/points when you destroy something? 1 Answer
Show score when enemy is destroyed C# 1 Answer
Please Help Me 1 Answer