Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
817 views
in Technique[技术] by (71.8m points)

c# - CS7036: There is no argument given that corresponds to the required formal parameter 'amount' of 'PlayerHealt.takeDamage(float)'

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...