I am trying to kill a mob of enemies that are coming at me at once. I summon a skill which hits all enemies around it. The skill and scripts work just fine except that the skill only hits one enemy at a time, instead of all the enemies around the skill. It would slowly damage one enemy then once that one enemy is dead, it begins hitting the next enemy in the damage zone. None of what is going on makes any sense to me but I would guess that the problem lies in the "Get component" portions of the script. Here are the two scripts(Enemy script and skill script)
Enemy script:
var Health : int = 50;
var MonsterLevel : int = 1;
var Alive = true;
var Me : GameObject;
var ExpGive : int = 5;
var ExpGiver : Stats;
var Infliction : Stats;
var DamageAmount : int = 7;
var CanHit = true;
var Invinsible : int = 1;
var CoinsGive : int = 0;
var EnemyInfo : GUIText;
var EnemyInfoText : GameObject;
var Blood : GameObject;
var ShowEXPText : GUIText;
var ShowEXP : GameObject;
function OnMouseEnter(){
EnemyInfoText.SetActive(true);
}
function OnMouseExit(){
EnemyInfoText.SetActive(false);
}
function Start(){
this.CoinsGive = Random.Range(1,10);
yield WaitForSeconds(Invinsible);
CanHit = true;
}
function OnTriggerEnter(Player : Collider){
if(CanHit == true && Player.gameObject.tag == "Player"){
Infliction = GameObject.Find("Player1").GetComponent(Stats);
Infliction.HealthNumber -= DamageAmount;
CanHit = false;
StartCoroutine("Start");
}
}
function OnTriggerStay(Player : Collider){
if(CanHit == true && Player.gameObject.tag == "Player"){
Infliction = GameObject.Find("Player1").GetComponent(Stats);
Infliction.HealthNumber -= DamageAmount;
CanHit = false;
StartCoroutine("Start");
}
}
function Update(){
EnemyInfo.text = "(Basic Cube) " + "Level: " + MonsterLevel + " Maximum health: " + Health;
if(Health <= 0){
Alive = false;
}
if(Alive == false){
EXPGiver = GameObject.Find("Player1").GetComponent(Stats);
ExpGiver.EXPHave += ExpGive;
ExpGiver.Coins += CoinsGive;
EnemyInfoText.SetActive(false);
ShowEXPText.text = "Exp + " + ExpGive;
ShowEXP.SetActive(true);
Destroy(Me);
}
}
and here is the Group attack skill script:
var Hit : Stats;
var Target : Level1Enemy;
var CanDo : int = 0;
function Start(){
Hit = GameObject.Find("Player1").GetComponent("Stats");
CanDo = Hit.Damage;
yield WaitForSeconds(6);
Destroy(GameObject.Find("Skill 2 Ancient Hammer(Clone)"));
}
function OnTriggerEnter(Enemy1 : Collider){
if(Enemy1.gameObject.tag == "Enemy"){
Target = GameObject.Find("EnemyLVL1").GetComponent("Level1Enemy");
Target.Blood.SetActive(true);
Target.Health -= CanDo;
}
}
Best of luck to whoever attempts this problem. I literally spent hours staring at these two scripts trying to figure out what the issue it with no luck. I don't think that the player script would be of any help, but if you do need it, please comment and I will update the post with it.
Thanks. Stan T.
↧