鍵盤控制方向
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)。