我想一些UnityScript代碼轉換爲d#和我收到以下錯誤:錯誤的UnityScript轉換爲C#
Expression denotes a method group, where a
variable
,value
ortype
was expected on the Getcomponent
void Update()
{
float xVel = GetComponent().Rigidbody2D().velocity.x;
if(xVel < 18 && xVel > -18 && xVel !=0){
if(xVel > 0){
GetComponent.Rigidbody2D().velocity.x=20;
}else{
GetComponent.Rigidbody2D().velocity.x = -20;
}
}
}
你試着實際分配'xVel'嗎? –
向我們展示GetComponent的代碼。 –
Getomponet是統一的內置方法http://docs.unity3d.com/ScriptReference/Component.GetComponent.html – Student