Thomas Burke
Games Designer, Developer & Rapid Prototyping

Making a Racing Game Framework Part 8
Last but not least we need some form of event in our gamemode, to set up our custom structure of players, (We normally want this to happen on game start or somethig similar) For mine I just call it whenever the server pressed the P character but thats just for testing purposes.
My custom event, (Called Begin Race) calls a "Refresh Spawn Points Function (It just finds all the active spawn points in the world and puts them into an array), then uses this Spawn Point array to spawn players and then add those players with default values to our custom player Information structure.
However we firstly (To make sure we don't cause any bugs, find all the current Pawns in the world and destroy them (So we don't get any random pawns in the world lollygagging round))

Now we just loop through all the "Current Players", in our game add them into our "Player Info Struct", then spawn a Pawn at the location of the appropiate Spawn points, (As long as there are less or an equal amount of spawn points in comparrison to players), (The actor transform is just an in-built structure containing "Location (Which is a 3D Vector), Rotation (Which is a Rotation Structure) and Scale (Which again is a 3D Vector).

Now we just loop through all the "Current Players", in our game add them into our "Player Info Struct", then spawn a Pawn at the location of the appropiate Spawn points, (As long as there are less or an equal amount of spawn points in comparrison to players), (The actor transform is just an in-built structure containing "Location (Which is a 3D Vector), Rotation (Which is a Rotation Structure) and Scale (Which again is a 3D Vector).

The last thing we need to do now is "Unposses" our controller (To free it from any references of its previous pawn) and then "Possess" our controller with our new pawn.