玩家控制器 及 摄像机组件
自定义控制器AMyPlayerCtrler
1
| class AMyPlayerCtrler : public APlayerController
|
重写几个方法
1 2 3 4 5
| virtual void PlayerTick(float DeltaTime) override; virtual void SetupInputComponent() override; virtual void ProcessPlayerInput(const float DeltaTime, const bool bGamePaused) override;
|
事件绑定的实现部分
1 2 3 4 5 6 7 8 9 10 11 12 13
| void AMyPlayerCtrler::SetupInputComponent() { Super::SetupInputComponent();
&AMyPlayerCtrler::OnSetDestinationPressed); InputComponent->BindAction("MouseClick", IE_Released, this, &AMyPlayerCtrler::OnSetDestinationReleased);
InputComponent->BindTouch(EInputEvent::IE_Pressed, this, &AMyPlayerCtrler::MoveToTouchLocation); InputComponent->BindTouch(EInputEvent::IE_Repeat, this, &AMyPlayerCtrler::MoveToTouchLocation); }
|
2、Editor中绑定上面几个事件
Edit > Project Settings > Input
