第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問代碼錯在哪里啊,找不到???

我用的代碼//var Speed = 50;//var Control;{//Control = GetComponent(js1);//if(Input.GetKey(KeyCode.W));{//Control.ForWard();}else if(Input.GetKey(KeyCode.S));{//Control.Back();}if(Input.GetKey(KeyCode.A));{//Control.GLeft();}else if(Input.GetKey(KeyCode.D));{//Control.GRight();}if(Input.GetKey(KeyCode.Q));{//Control.leftRotate(Vector3.up *Time.deltaTime * -Speed);}else if(Input.GetKey(KeyCode.E));{//Control.RightRotate(Vector3.up *Time.deltaTime * Speed);}}錯在那里呢?
查看完整描述

1 回答

?
MMMHUHU

TA貢獻1834條經(jīng)驗 獲得超8個贊

要這樣寫
var Speed = 50;
//
var Control;

function Update(){ //要用Update()方法
//
Control = GetComponent("js1"); //GetComponent()里面填的是字符串類型。
//
if(Input.GetKey(KeyCode.W)) //if(xxx)后面是沒有" ; "的
{
//
Control.ForWard();
}else if(Input.GetKey(KeyCode.S))
{
//
Control.Back();
}
if(Input.GetKey(KeyCode.A))
{
//
Control.GLeft();
}else if(Input.GetKey(KeyCode.D))
{
//
Control.GRight();
}
if(Input.GetKey(KeyCode.Q))
{
//
Control.leftRotate(Vector3.up *Time.deltaTime * -Speed);
}else if(Input.GetKey(KeyCode.E))
{
//
Control.RightRotate(Vector3.up *Time.deltaTime * Speed);
}
}

鑒于規(guī)范和效率問題,應(yīng)該是要這樣寫
規(guī)范:變量名(var 變量名 : 類型)開頭字母小寫,方法名(function 方法名(){})開頭字母大寫。
效率:聲明變量時應(yīng)該都定義好變量類型, GetComponent.<js1>();比 GetComponent("js1”);更好
var speed : int = 50; //改成小寫開頭
//
var control : js1; //改成小寫開頭,js1這個類名應(yīng)該也要大寫開頭才規(guī)范

function Update(){
//
control = GetComponent.<js1>();
//
if(Input.GetKey(KeyCode.W))
{
//
control.ForWard();
}else if(Input.GetKey(KeyCode.S))
{
//
control.Back();
}
if(Input.GetKey(KeyCode.A))
{
//
control.GLeft();
}else if(Input.GetKey(KeyCode.D))
{
//
control.GRight();
}
if(Input.GetKey(KeyCode.Q))
{
//
control.LeftRotate(Vector3.up *Time.deltaTime * -speed); //原來這里的leftRotate我改成大寫了,注意一下
}else if(Input.GetKey(KeyCode.E))
{
//
control.RightRotate(Vector3.up *Time.deltaTime * speed);
}
}


查看完整回答
反對 回復(fù) 2023-04-27
  • 1 回答
  • 0 關(guān)注
  • 261 瀏覽
慕課專欄
更多

添加回答

了解更多

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號