I have a vehicle pawn that is a tank. It replicates wonderfully on both players screens, but to keep it short and sweet, how do I go about making it possessable by more than one player so that one controls the driving, and the other will control the shooting? Help understanding this logic would be greatly appreciated, thanks in advance.
PlayerControllers and Pawns have a one to one mapping.
You will need one Pawn that controls the driving, and another Pawn that controls the shooting.
Are you aware if that is a good/standard solution? I only ask because I have no clue about what’s standard in MP dev. I’ve used it for ai possessed pawns attached to the player pawn in the past, but that was a SP game, I’m absolutely unsure what pitfalls arise from using this method in client to server model MP. Thanks for your suggestion!
Good question!
I’d say that it has to be a good solution, due to the aforementioned one to one mapping.
Make tank as AI possessed pawn.
Create 2 modes for player pawns: normal FPS/shooting etc, and in tank invisible.
Instead of possessing Tank pawn (attach player pawns to it), then just swap mode to invisible, hook/transfer player input (events) to Tank Pawn and then to tank AI.
Create simple AI that just gets both (multiple) players inputs, when they attach to Tank Pawn. And acts upon input.
So when players attach to tank pawn, possess it with that simple AI, else posses it with enemy AI.
I’ve done this and added full functionality in my tank, but I’m having trouble making two different camera perspectives for the driver and the gunner.
The players get inside the vehicle, and I use set view target with blend to the tank actor, but it only uses the active camera. If I swap the active camera, it swaps it for both players, giving them identical perspectives.
How would you suggest giving them two different view perspectives? I’ve already set up controls to independently move the turret which has the gunners camera attached, and the drivers third person springarm independently, just not sure how to separate the two clients perspective.