QA: ## 設定一個玩家進入/離開特定區域的特殊事件 可以在觸發區設定一個新 collider (勾選 Trigger),然後掛上 TriggerEventPoint 腳本,設定進入,離開時的事件  或是可以寫針對玩家 Collider 的特殊設定,另外寫腳本控制碰撞物是GetComponent<CharController>() 是自身玩家,進行特定處理 ```C# if (collider.GetComponent<CharController>() != null) { // 自身玩家的特殊處理 } ``` ## 想要讓手持武器可以對其他玩家有特殊效果, ex: 擊飛他人 可以在武器模型上綁碰撞器 (勾選 Trigger),開 Rigidbody 物理,然後寫腳本當碰撞物為 GetComponent<Agent>(),即可獲取 Actor 判斷是否為其他玩家,方可進行 AddForce 與調整力量大小。 ```C# if (collider.GetComponent<Agent>().GetActor().IsCharSelf() == false) { // 其他玩家的特殊處理 } ``` ## 強制裝備指定武器 ```C# string equipId = "IWP9999"; MapManager.GetInstance().GetCharSelfActor().SetPropUse(equipId); ``` ## 自定義武器操作模式 可以武器物件 prefab 本身增加 UI 控制,進行顯示與狀態更新 - 參考 <font size=3 color=#f00000>CoreDLC/Bundles/CoreFrame/UI/PropExtdUI/FPSUI</font>  可以在 UI 中的 OnShow 綁定事件,例如按下滑鼠左鍵等 - 實現 PropExtdUI 時,必須注意繼承關係 ```C# // 必須繼承 PropExtdUI 該類 public FooUI: PropExtdUI { // 開啟時啟動綁定滑鼠左鍵事件 protected override void OnShow(object obj) { OxGKit.InputSystem.Inputs.IA.GetInputAction<PlayerAction>().onMouseLeftAction += _OnMouseLeftUse; // 其他設定 } // 結束時啟動解除滑鼠左鍵事件 protected override void OnClose() { OxGKit.InputSystem.Inputs.IA.GetInputAction<PlayerAction>().onMouseLeftAction -= _OnMouseLeftUse; } } ``` 可以在武器 SourceObj 本身設定另外 script,設定額外的邏輯處理 - 建議於自身的 DLC 底下的 Scripts/Hotfix/ 創建路徑名為 <font size=3 color=#00a000>GamePlay/PropExtd/\<Your_Function_Name\>/PropExtdObjs</font> 的文件夾,進行武器額外 script 的歸類。  ## 設定玩家離開特定邊界時的事件處理 可以在 Collider 物件上掛載 ObjectTriggerControl (可以想成 TriggerEventPoint 的高階版) ,此範例為當玩家碰到邊界 collider 時,設定位置到指定的位置,可以自己定義新事件  ## 搭乘交通載具 可以在 Collider 物件上掛載 ObjectTriggerControl  設定 Enter 時觸發 SetCharSelfActorAttach 到特定 Transform 這個 Transform 就是特定載具 設定 Exit 時觸發 SetCharSelfActorAttach() 解除搭乘
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up