Question by
Psyebrgames · Oct 13, 2017 at 03:35 PM ·
variablefunctionmethodfunction call
basically Tried to make own attack function and not getting health returning where function called from.
below you can see my code i have wrote .
public static float doAttack(float attackPower, float healthPool)
{
Debug.Log("this is working but not not taking health off????");
healthPool -= attackPower * Time.deltaTime;
//health -= 500 * Time.deltaTime;
return (healthPool);
}
and here is where i call it from.
void OnTriggerEnter2D(Collider2D other)
{
attack.doAttack(attackForce, health);
}
as you can I pass in my variable but dont seem to get the return since the health doesnt decrease can anyone put out where i am going wrong.
Comment
Best Answer
Answer by Psyebrgames · Oct 13, 2017 at 03:43 PM
Answered my self lol ended up I sorted and will post code below so anyone with similar can see where i was going wrong .
void OnTriggerEnter2D(Collider2D other)
{
health = attack.doAttack(attackForce, health);
}
so yet was making the call but wasnt telling my code why it was making the call and what variable was going to be effected.
Your answer
Follow this Question
Related Questions
Script not returning value to other script 1 Answer
Invoking Func Memory Allocation workaroud 1 Answer
Method Group 1 Answer
MoveTowards instantly repositioning object to target position 2 Answers
Use a class like a function 1 Answer