//跳跃开始 void JumpStart(); //跳跃结束 void JumpEnd();
void APlayingCharacter::JumpStart() { //如果是真的话,角色跳跃 bPressedJump = true; } void APlayingCharacter::JumpEnd() { //如果是假的话,结束跳跃 bPressedJump = false; }
void APlayingCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); InputComponent->BindAxis("MoveForward",this, &APlayingCharacter::MoveForward); InputComponent->BindAxis("MoveBack",this, &APlayingCharacter::MoveBack); InputComponent->BindAxis("MoveRight",this, &APlayingCharacter::MoveRight); InputComponent->BindAxis("MoveLeft",this, &APlayingCharacter::MoveLeft); InputComponent->BindAxis("Turn", his, &APawn::AddControllerYawInput); InputComponent->BindAxis("LookUp",this, &APawn::AddControllerPitchInput); InputComponent->BindAction("Jump",IE_Pressed,this,&APlayingCharacter::JumpStart); InputComponent->BindAction("Jump", IE_Released, this, &APlayingCharacter::JumpEnd); }BindAction 是一种 “状态”按键输入类,IE_Pressed 表示的是按下的时候执行JumpStart() 函数,IE_Released 表示的是松开的时候执行JumpEnd()事件。BindAxis 按键绑定类型是可以一直按一直执行的,而 BindAction 是按一次执行一次事件。松开执行一次事件,BindAction也可以不配套使用。
本文链接:http://task.lmcjl.com/news/18906.html