How to stop reading pitch input unless targeting


I am trying to restrict my game so that the player can only look up/down when the player is already targeting.

I currently have pitch mapped to mouse y and targeting to the mouse right button, so I am trying to make it so that the player can only look up/down when pressing the right mouse button. i.e. I want to stop reading pitch input unless it is pressed.

But, I am a bit lost as to how I can stop reading the pitch input when the player is not targeting - I am assuming I could achieve this by clamping pitch at 0?

Any advice/help would be greatly appreciated.

you can do something like this (based on FPS c++ template):

void ATP_FirstPersonCharacter::LookUpAtRate(float Rate)
	// calculate delta for this frame from the rate information
	      AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
          FRotator CurrRotation = GetController()->GetControlRotation();

You will need of course to map the targeting action to switch on and off the bIsTargeting.

It probably seems silly, but I didn’t realize I could declare my own method for the input mapping to replace addcontrollerpitchinput.

That has made it loads easier and helps me with loads of other things too :slight_smile: thanks

I ended up moving the else logic into my end targeting method to handle the case where the player stops targeting but doesn’t try to alter pitch.

Thanks again