I didn’t put any c++ stuff in my response above… if youre talking about HandleThrottle, I meant that is a function you create in your MotorcyclePawnBP to take input and apply it to whatever system you’re using to move the pawn around (systems like Chaos Vehicle, MovementComponent, custom velocity stuff)
This is how I would implement a handlebar(names may be a bit different i dont vr sample open):
Create an IMC_ThrottleHandle, this has IA_HandBrake on oclulus control R hand trigger as a axis 1D input, IA_Throttle mapped to X
In your RightHandleBarBP’s
VRGrabcomponent->OnGrabbed:
PlayerController(0)->EnhancedInput..->AddMappingContext(IMC_ThrottleHandle)
OnReleased (or whatever the event for releasing is):
PlayerController(0)->EnhancedInput..->RemoveMappingContext(IMC_ThrottleHandle)
Then, in your MotorcyclePawnBP, you create events to handle the inputs. These events only get called when the MappingContext is added, so wont fire when the handle isnt grabbed.
EnhancedInput.. IA_Throttle → Started (fires when action starts) → “HandleThrottle” (your custom fcn)
EnhancedInput.. IA_Throttle → Canceled and Completed → “ZeroThrottle” (another custom fcn to set your throttle to 0)
You might pipe in the ActionValue into an input on HandleThrottle for you to use in your motion system, if you need it. Buttons(digital bool) will return 0 or 1, triggers(axis 1D) return a range 0 to 1 depending on how much the trigger is pulled.
For a handbrake:
EnhancedInput.. IA_Handbrake → Triggered (fires continuously) → “HandleHandBrake” (your custom fcn)
Same as above for canceled/completed.
For a trigger or thumbstick axis, use Triggered as Started only gets called when you first start the input, Triggered is called on tick and allows the ActionValue to get piped in constantly.
You can create an IMC_ClutchHandle for left hand. Or IMC_Right_Mirror if you wanted to create a right hand mirror to adjust for instance. Follow the same pattern.
You can look at the VRPawn’s beginplay to see this in action for assigning the input context. and how the inputs are handled there.
To possess a pawn you do PlayerController->Possess(self) like in your MotorcyclePawnBP, or you can possess within your custom Playercontroller BP with a reference to the pawn calling Possess(mymotorcycleBPref). Either way works fine, I prefer the second as it keeps possession logic in my playercontroller.
Tons of info/vids out there of possessing vehicles/etc essentially doing the above… its the same for VR, you just have to set up the pawn you want to possess as a ‘VRPawn’ essentially.
For possession of different vehicle pawns, Instead of BeginPlay use ReceiveControllerChanged event in your pawnBP to clear and add initial MappingContexts. This fires when the pawn is possess/unpossessed. Beginplay will only fire once when the pawn is initialized.