Attach Pawn to Another Pawn? Hull/Turret Setup - Multicrew

I’m using BoredEngineer’s plugin for making tanks and I’m playing around with a little prototype of mine, basically, I’m trying to make a tank that is multicrewed - in other words, the tank is controlled by more than 1 player.

Initially I’m going for a simple driver/gunner setup but in the future I may add slots of machinegunners and commanders depending on how well it works.

However, I can’t seem to figure out how to accomplish this. Both the hull and the turret needs to be a pawn*(or at least I assume so, since both need to receive input)* but I can’t figure out how to attach a pawn to another.

Or is there a better approach? Currently the turret is just an actor. Any help is greatly appreciated!

How about the turret is a component of the hull pawn? Would that work?

How about creating editable/public dataset(or something like that) variable array in which you would store pawns and their relative positions or socket names? You could even create base class from this and all of your tanks could be inherited from this so you can store them in some kind of array.

id buy this asset Multiplayer Passenger Vehicle in Blueprints - UE Marketplace - i did to learn how to do this.

Actor can receive input as well. You just need to call the appropriate Enable Input and give the appropriate PlayerController. And you can use Attach actor to actor to connect turret to hull , to the socket of the Hull.

Thanks for the input guys, I’ll be checking them out. The package linked by BPANDREW does look very interesting as it also has multiplayer support which would be very interesting to have a look at.

It’s currently attached as a separate actor using a socket so I’ll be checking your method out, Holybreath. More advice and suggestions are welcome - I’ll report back with results once I get around to testing this, in case this is useful information for others as well.

Tried the Enable Input method but can’t get it to work at all. I add my turret as a child actor to the main part of the tank.

In the turret BP, I try to enable input upon begin play - however I am still unable to do any sort of input of any kind via the client(my tank being the server).

You have stepped into a wonderful world of networking, my friend :slight_smile: What you need is custom events now. In pseudo code it looks like this:

  1. Client presses a key
  2. A custom event with replication set to ‘Run on server’ is called. Throw in a clients controller into variables of custom event.
  3. Server uses to controller to determine which player pressed the key and do the action.
  4. server then execute a custom event with ‘Run on all clients’ to tell every client that this code needs to be executed now.
    I suggest reading/watching lots of networking. This is probably the hardest part for beginners to understand.

I’m not entirely new to networking, though. I’ve done plenty of client/server interaction back in the day with Lua so I’m familiar with how authority and such works as well as passing necessary variables.

The issue I’m having however is that I can’t even get an actor to receive input locally. I tried to enable input upon begin play for player controller index 0, I then tried to set up a Hello World message when I press F.

I simply couldn’t get it to work. Will be doing some more testing and research today. :slight_smile: Thanks for your reply though!

Is your actor being possessed? BeginPlay of which actor?

Well, I’m slowly making progress. I played around a bit now and I’ve made it so I spawn both the hull and the turret and I’m able to attach the turret to the hull at the proper location and it seems to work thus far.

Now remains how to figure out how to control it all, to me it seems like a separate control for each tank member would be the best way to go.

So for now, the driver which has all the physics stuff related to driving the tank - and a separate controller for the turret.

However, how would I go about achieving this? Since I can only choose one kind of controller under the World Settings? I tried to look through the various functions but I can’t seem to find a function that lets me change the kind of controller - unless I’m entirely blind.

Create a new blueprint based on player controller, and then cast playercontroller node to your blueprint.

Hey, sorry for the late response. I’ve mostly got it all working now. The remaining issue is that the hull of the tank is a separate actor which relies on a unique controller.

I’ve made it so I can host a game and join it and it’s all setup automatically. Only issue is that my turret can’t yet be controlled as I’m still trying to figure out if it’s possible to use 2 separate controllers during a game.

I really don’t want all of my stuff to be in the one same controller BP as it would be incredibly messy.

I second this! I found these assets really useful.

PS: You don’t need to use them specifically in your project per se. But they are very helpful in showing you some neat tricks for achieving multi-crewed vehicles.