Unity3d Unity项目错误CS0136:名为“distanceBall';无法在此作用域中声明,因为

Unity3d Unity项目错误CS0136:名为“distanceBall';无法在此作用域中声明,因为,unity3d,Unity3d,我有一个脚本告诉我错误: Assets/Soccer Project/Scripts/Player_Script.cs(493,11):错误CS0136:无法在此范围内声明名为“distanceBall”的局部变量,因为它将赋予“distanceBall”不同的含义,而“distanceBall”已在“child”范围内用于表示其他内容 我在网上找不到任何好的答案,也不知道如何解决,以下是脚本: 使用UnityEngine; 使用制度; 使用系统集合; 公共类玩家脚本:MonoBehavior{

我有一个脚本告诉我错误:

Assets/Soccer Project/Scripts/Player_Script.cs(493,11):错误CS0136:无法在此范围内声明名为“distanceBall”的局部变量,因为它将赋予“distanceBall”不同的含义,而“distanceBall”已在“child”范围内用于表示其他内容

我在网上找不到任何好的答案,也不知道如何解决,以下是脚本:

使用UnityEngine;
使用制度;
使用系统集合;
公共类玩家脚本:MonoBehavior{
//球员姓名
公共字符串名称;
public TypePlayer type=TypePlayer.DEFENDER;
公共浮子速度=1.0f;
公共浮动强=1.0f;
公共浮动控制=1.0f;
私人常量浮点耐力分割器=64.0f;
私人常量浮动耐力_MIN=0.5f;
私人常量浮动耐力_MAX=1.0f;
公用枚举打字机{
防守者
米德勒,
攻击者
};
公共向量3实际位置层;
专用矢量3 oldVelocityPlayer;
公共领域;
私人游戏对象[]玩家;
私有游戏对象[]组件;
公共向量3重置位置;
公共向量3初始位置;
私人浮动输入;
私有常量浮点初始位移=20.0f;
公共转型目标定位;
公共转型;
[hideininstecpt]
public bool temporallyunselective=true;
[hideininstecpt]
可选择的公共浮动时间=1.0f;
公共浮点数maxDistanceFromPosition=20.0f;
公共枚举播放器_状态{
准备开球,
踢你的提议,
休息,
去你的原点,
控制,
经过,
射击
自动移动,
退一步,
偷球,
奥本特·尤攻击,
挑球,
改变方向,
把你扔进去,
角球,
解决
};
公共玩家(州);;
专用浮动时间移动=3.0f;
专用浮动时间通行证=1.0f;
//斯奎尔顿等级中的玩家之手
公手骨;
公共InGameState_Script inGame;
公共结构;
公共结构;
私有位置=0;
私有四元数初始旋转;
公众漂浮耐力=64.0f;
无效唤醒(){
GetComponent().Stop();
状态=球员状态。准备开球;
}
无效开始(){
//获取玩家和oponent并将其保存在两个数组中
players=GameObject.FindGameObjectsWithTag(“PlayerTeam1”);
oponts=GameObject.FindGameObjectsWithTag(“opontteam”);
resetPosition=新矢量3(transform.position.x,transform.position.y,transform.position.z);
如果(gameObject.tag==“PlayerTeam1”)
初始位置=新矢量3(transform.position.x,transform.position.y,transform.position.z+初始位移);
如果(gameObject.tag==“opontteam”)
初始位置=新矢量3(transform.position.x,transform.position.y,transform.position.z-初始位移);
//设置动画速度以适合完美的动作
GetComponent()[“向后跳”]。速度=1.5f;
GetComponent()[“启动”]。速度=1.0f;
GetComponent()[“启动球”]。速度=1.0f;
GetComponent()[“正在运行”]。速度=1.2f;
GetComponent()[“跑动球”]。速度=1.0f;
GetComponent()[“通过”]。速度=1.8f;
GetComponent()[“rest”]。速度=1.0f;
GetComponent()[“转动”]。速度=1.3f;
GetComponent()[“滑车”]。速度=2.0f;
GetComponent()[“战斗”]。速度=1.2f;
//jugadores酒店
GetComponent().Play(“rest”);
initialRotation=transform.rotation*headTransform.rotation;
}
//实际玩家的控制
无效案例(){
if(sphere.inputPlayer==游戏对象){
if(sphere.f垂直!=0.0f | | sphere.f水平!=0.0f){
oldVelocityPlayer=实际位置层;
Vector3 right=inGame.transform.right;
Vector3 forward=inGame.transform.forward;
右*=球体水平;
向前*=球面垂直;
Vector3目标=变换位置+右+向前;
target.y=transform.position.y;
浮动速度为5.0f;
//如果他是球的主人。。。。
if(sphere.owner==游戏对象){
if(GetComponent().IsPlaying(“rest”)){
GetComponent().播放(“起始球”);
飞行速度=1.0f;
}
if(GetComponent().IsPlaying(“起始球”)==false)
GetComponent().玩(“跑球”);
}
否则{
if(GetComponent().IsPlaying(“rest”)){
GetComponent().Play(“开始”);
飞行速度=1.0f;
}
if(GetComponent().IsPlaying(“启动”)==false)
GetComponent().Play(“running”);
}
变换。注视(目标);
浮动耐力MP=数学钳制((耐力/耐力分割线)、耐力最小值、耐力最大值);
ActualLocationPlayer=变换。前进*飞行速度*时间。延迟时间*飞行速度*速度;
transform.position+=实际位置图层;
//如果得到一个根本不同的方向的球员改变动画。。。
float dotp=Vector3.Dot(oldVelocityPlayer.normalized、actualLocationpLayer.normalized);
如果(
if (...)
{
    float distanceBall;
}

float distanceBall;
float distanceBall;

if (...)
{
    ...
}

...