CG 數位學習網 > Corgi Engine 教學



Corgi Engine Input 輸入設定

https://www.youtube.com/watch?v=miZyco9NWDQ

基本介紹

 

預設輸入

 

輸入設定 - 如何修改操作按鈕

 

Input Manager 與 GUI

 

Player ID

重要! CorgiEngine 可以從 InputManager 傳送 Input 到場景中的玩家角色 (objects with a Character component whose type is set to Player). 每個 InputManager 都有一個 PlayerID attribute, and it’ll send its information to all characters whose own PlayerID attribute match it. So there are a few ways this can work :

  • The most common way is to simply let the engine handle this. Add an InputManager to your scene, set its PlayerID to “Player1”. Then in the LevelManager, when you add your character, have the “Auto attribute player IDs” checkbox checked, and it’ll automatically give the playable character the “Player1” ID. If you are in a multiplayer level use “Player2”, “Player3” and “Player4”. You can add your own of course, but these are the default ones.
  • You can also set the PlayerID on the prefab. For example you could have a Dog character, whose PlayerID is “JoeTheDog” (why not?). If you add an InputManager to your scene and want it to target that Dog character, set its own PlayerID parameter to “JoeTheDog”. Press play and you should be able to control your Dog character. That method is great if for some reason you don’t want to use the Level Manager and want to instantly move a prefab in the scene.

I use that second method a lot when tweaking a character. Let’s say I want to change the Jump behaviour of my character. I’ll just copy my character’s prefab, put that copy in the scene, set its PlayerID to Player1. Then in the LevelManager I put the original prefab as the Player Prefab. I press play and I’m now controlling two characters with the same input. I can then change the jump settings on one of them (or even add a new Jump script in place of the old one), and play test both very fast to see if my changes are improving the gameplay.

 

自動偵測行動裝置 ( Auto Mobile Detection  ) 運作原理

選取 InputManager 輸入管理物件,透過 Inspector 可以將 Auto Mobile Detection 自動偵測行動裝置功能開啟或關閉。

展開 UICamera 預製物件將可看到包含多個子物件, and notably Arrows, Joystick and Buttons canvas groups. 預設的情況這些物件是關閉的狀態,但您需要的話可以將這些物件開啟 or to tweak them. These are then bound to the GUIManager component (among other stuff). Mobile detection works in a very simple way : 若您是製作行動裝置遊戲,按下 Play 時它們將會顯示於畫面,If you’re targeting another platform, it’ll hide and disable them. You can also force one mode or the other from the inspector.

例如開啟 MinimalLevel 場景,選取 UICamera 物件,從 Inspector 確認 Auto Mobile Detection 為勾選狀態。

 

虛擬方向鍵、虛擬搖桿、虛擬按鈕

開啟 [ CorgiEngine > ThirdParty > MoreMountains > MMTools > Tools > MMControls > Demo ] 資料夾的 MMControlsDemo 場景,展示 Corgi Engine 提供的虛擬搖桿、虛擬按鈕。