错误cs1501unity3d我试图让我的角色在按下某个键时闪避,但我一直收到这个错误CS1501:MethodDodge'takesnooverloadDodge'takes2argumentswhichis闪避部分脚本这是完整的脚本,闪避部分在最后使用UnityEngine;使用系统集合;公共类播放器:MonoBehaviour{publicintplayerHP;公共GUIStyle大字体;公共intattackPlayer;公共intdefensePlayer;公共intspeedPlayer;;公共int损坏;publicenumDodgeDirection{右,左,前,后};publicVector3闪避=newVector3(5,5,5);//使用它进行初始化voidStart(){playerHP=500;大字体=新的GUIStyle();bigFont.fontSize=40;攻击玩家=10;防御玩家=8;速度播放器=10;atckSpeedPlayer=12;}//每帧更新调用一次-防御玩家;playerHP-=伤害;}}publicvoidOnGUI(){图形用户界面。Label(newRect(180,800,100,50),"HP:"+playerHP.ToString(),fonteGrande);//determinaposi?aoetransformaovaloremstring}publicvoidDodge(DodgeDirectiondir){switch(dir){caseDodgeDirection.Right:rigidbody.AddForce(transform.right*dodge.x+transform.up*dodge.y,ForceMode复制代码。冲动);休息;caseDodgeDirection.Left:rigidbody.AddForce(transform.right*dodge.x+transform.up*dodge.y,ForceMode.Impulse);休息;caseDodgeDirection.Forward:rigidbody.AddForce(transform.forward*dodge.z+transform.up*dodge.y,ForceMode.Impulse);休息;caseDodgeDirection.Backward:rigidbody.AddForce(transform.forward*dodge.z+transform.up*dodge.y,ForceMode.Impulse);休息;}}voidFixedUpdate(){if(Input.GetKeyDown("l")){Dodge(DodgeDirection.Right,dodge);//返回;}elseif(Input.GetKeyDown("j")){Dodge(DodgeDirection.Left,dodge);//返回;}elseif(Input.GetKeyDown("i")){Dodge(DodgeDirection.Forward,dodge);//返回;}否则我f(Input.GetKeyDown("k")){闪避(DodgeDirection.Backward,闪避);//返回;您通过传递两个参数来调用Dodge方法,例如:Dodge(DodgeDirection.Forward,dodge);但是你的方法只需要一个:publicvoidDodge(DodgeDirectiondir)所以为了解决这个问题,你有两个选择:以上是C#学习教程:errorcs1501unity3d分享的全部内容,如果对大家有用并且需要了解C#学习教程的更多内容,希望大家多多关注——在FixUpdate方法中只传递一个参数,在方法的签名中添加第二个参数。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
