2018-09-17

鍵盤控制方向

1.主光源刪掉,新建一個(gè)Plane,一個(gè)Cube,一個(gè)Point Light,Point Light拉進(jìn)Cube里;

2.Point Light放到Cube的正上方合適位置,Cube拉伸到合適大?。?/p>

3.選中“Main Camera”,設(shè)置一個(gè)狀態(tài);設(shè)置狀態(tài)“Smooth Look At”,“Game Object”設(shè)置為“Use Owner”,把“Cube”拉進(jìn)“Target Position”;

4.選中Cube,添加“go run”和“go walk”兩個(gè)事件,state1添加過渡“go run”,狀態(tài)1添加過渡“go walk”;

5.選中“go run”,設(shè)置“Get Axis Vector”、“Controller Simple Move”、“Smooth Look At Direction”、“Get Button Down”四個(gè)狀態(tài);“Get Axis Vector”的“Store Vector”新建變量“movement”;“Controller Simple Move”的“Game Object”設(shè)置為“Use Owner”,“Move Vector”設(shè)置為“movement”,“Speed”新建變量“walk speed”;“Smooth Look At Direction”的“Target Direction”設(shè)置為“movement”,“Speed”設(shè)置為2;“Get Button Down”的“Send Event”設(shè)置為“go run”;

6.選中“go walk”,設(shè)置“Get Axis Vector”、“Controller Simple Move”、“Smooth Look At Direction”、“Get Button Up”四個(gè)狀態(tài);“Get Axis Vector”的“Store Vector”新建變量“movement”;“Controller Simple Move”的“Game Object”設(shè)置為“Use Owner”,“Move Vector”設(shè)置為“movement”,“Speed”新建變量“run speed”;“Smooth Look At Direction”的“Target Direction”設(shè)置為“movement”,“Speed”設(shè)置為2;“Get Button Up”的“Send Event”設(shè)置為“go walk”;

7.在變量中分別點(diǎn)一下“run speed”和“walk speed”,設(shè)置值大于0,否則Cube只能原地轉(zhuǎn)圈,不能移動(dòng);

8.“WASD”控制方向,“Cube”就會(huì)移動(dòng)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容