So I have a few questions here. I’ll give a brief explanation of what I’m trying to accomplish so there is some context, even if this specific instance doesn’t get solved, I’d like some thought process on what the best way would be to achieve what I’m looking for.
Its a local multiplayer game (all players on 1 PC) using 4 Gamepads (xbox 360). Each player has a character that can sprint, jump, and use a unique ability. The players will be basically running an obstacle course as a race, and use their abilities anyway they can to get to the end. I have my character setup and running, I built all of my functionality in myCharacter and then I use a “playerNum” variable to give each player slot their specific ability. (I’ll post screenshots for all of this as well.)
At one point I wanted to make all my functionality in myCharacter and then make copies based on it and hook up the stuff I needed for that “character” but with the overrideable functions and what not I couldn’t quite figure out how to get it to work.
I’m trying to spawn characters at the game start, 1 for each gamepad, in the future I’d like to let the player pick their character on another screen, and then spawn them all with their selected characters, but for now I’m just trying to get the spawning working properly with fixed characters in each gamepad slot. Heres how I am getting a second player in game currently.
This is working, technically. Gamepad 1 controls the defaultPawn that is spawned from a player start. Gamepad 2 controls the spawned and possesed pawn in the screenshot, I can’t test anymore gamepads, but I’m assuming they will work. This is coming off of BeginPlay event in my Level blueprint currently. I wanted to move it to my gameMode construction script, but couldn’t access the spawning nodes, maybe I should make a function out of it? My problem with the current setup, is I get a 3rd pawn spawned, that just floats in air (assuming its unpossessed and chilling). But I’m not sure why it spawns in general? I only have 1 player start, for the defaultPawn to spawn at automatically. The second player is spawning currently at a specific location.
Heres a quick reference to how I’m handling the unique abilites based on “playerNum” and the movement of each possesed pawn.
My final question is about killing, respawning and possessing the new pawn. I will manually place spawn/checkpoints throughout the map. I’ll also place a volume at the bottom of the map and if players fall into it they should die and respawn at the closest spawn point. (I know I could use killZ, but the maps are kind of dynamic in the Z direction and it might take a long time to fall to the lowest killZ.) My Current setup looks like this.
I’ve commented it to help explain what I -think- I am doing. However it is failing at the cast to myCharacter.
Here is the findNearestSpawn function.
Sorry if thats a lot of text but I wanted to be thorough so that you have all the info you might need to help me figure this out. Either the direct issue or hints at how I could implement this stuff in better places (gameMode? Construction scripts, playerController, etc etc)