I have been trying to build a A takeDamage function in my game but it keeps giving me this error:
There is no argument given that corresponds to the required formal parameter 'amount' of 'PlayerHealt.takeDamage(float)'
Here is the code that im using:
public void takeDamage(float amount)
{
currentHealt -= amount;
if (currentHealt <= 0f)
{
//Death
}
}
(Player healt)
And this is the enemy's attack code:
private void AttackPlayer()
{
agent.SetDestination(transform.position);
transform.LookAt(player);
RaycastHit hit;
if (!alreadyAttacked)
{
if (Physics.Raycast(EnemyShootPoint.transform.position, EnemyShootPoint.transform.forward,
out hit));
{
PlayerHealt player = hit.transform.GetComponent<PlayerHealt>();
player.takeDamage(enemyDamage);
GameObject impactGameObject = Instantiate(impactEffect, hit.point,
Quaternion.LookRotation(hit.normal));
Destroy(impactGameObject, 1f);
alreadyAttacked = true;
Invoke(nameof(ResetAttack), timeBetweenAttacks);
}
}
}
From What i understand I need to give an argument to the 'amount' parameter.
I'm fairly new to programming and any help would be appriciated.
The problem is on line 1 according to the debugger.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…