Hello I need help.
I have a player that has 2 childs - Sword and a SwordHitBoxCollisionObject.
My player object has 2 swords that deal different amount of Damage ( 50 and 20 ).
The Sword has this script
public Transform Ruka;
public int Damage;
void Update()
{
transform.position = Ruka.position;
transform.rotation = Ruka.rotation;
}
and the SwordHitBoxCollisionObject that gets enabled when the player attacks (This object is supposed to deal damage) and has script that has
public int FinalDamage.
then I have Enemy object that doesn’t move.
with this script
public float maxHEALTH = 100;
public float currentHEALTH;
public int amount;
void Start()
{
currentHEALTH = maxHEALTH;
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
currentHEALTH = currentHEALTH - amount;
}
}
void Update()
{
if (currentHEALTH <= 0f)
{
DIE();
}
}
void DIE()
{
Destroy(gameObject);
}
My question is How do i get the Damage variable from the sword into the SwordHitBoxCollisionObject so that it would deal the same amount of damage to the enemy as in the Sword script ?
I can’t find a way how to do this.Creating public voids TakeDamage didn’t worked for me.
(Swords are controlled by the players animations = always folows hand)
Anybody knows how to fix this ?