HI
I wrote this code:
public GameObject manaBar;
public float amount;
public float countDown;
public float newLength;
public float currentLength;
public float posCountdown;
public Vector3 newManabarPos;
void Start()
{
damage(1.5f);
}
void Update ()
{
if(amount <= 0)
{
Debug.Log("DEAD");
}
}
public void damage(float dmg)
{
countDown = dmg/10;
currentLength = manaBar.transform.localScale.y;
newLength = currentLength - countDown;
manaBar.transform.localScale = new Vector3(manaBar.transform.localScale.x,newLength,manaBar.transform.localScale.z);
posCountdown = newLength/2;
newManabarPos = new Vector3(manaBar.transform.position.x,posCountdown,manaBar.transform.position.z);
manaBar.transform.position = newManabarPos;
}
its all work fine but the problem is when I run the game the y of the object is 6,its need to be -0.075
because I splited the variable to 2
1.5/2=0.075 and then I assign it to the y axis of the object
but for some reason the y of the object its -6 something
thx for all the helpers