Hi everybody. I have this code that goes something like this (abv versions but all the important stuff is in there)
var playerAtt; //player attacking damage
//some other stuff
//thypes of attack functionsfunction Slash()
function Atk1()
{
//dice roll to see if attack hits
dice = UnityEngine.Random.Range(1,50);
//playerAtt used for attack
playerAtt = slash * dice;
print("Slash");
print(playerAtt);
return playerAtt;
}
Ok so this is in one js file for the main character Now I have a second js script to handel input and other items that goes like this;
//this works
//this choses the type of attack and see if player can attack
//also handles input for player
function InputPlayer()
{
var attack = GameObject.Find(player1);
var bar = GameObject.Find(player1); //ignore this line
if(Input.GetKeyDown(KeyCode.X)) //slash attack
{
if(atBar.pixelInset.xMax == 150) {//see if atbar is full
attack.GetComponent(player1).Atk1();
bar.GetComponent(player1).AttBar();
}else (print("Cant Attakc"));
}
ok so far so good. All of this works fine and everything is returning as it should. Here is the problme. I have a enemy
that has some health and when I hit the attack button I want the damage from the variable playerAtt to subtrack from the enemy health. But I cant seam to get the int value from playeratt. How can I access the vaule from the first js script?
Thanks for any help here.