Game Development Reference
In-Depth Information
Getting ready
Start by having your IDE open and ready to make some changes. We won't have to create any
new classes, but we will alter the behavior of our existing ones by adding some functions.
How to do it...
1.
Let's begin by overriding the SpawnDefaultFor() function in our TutorialGame
class. Once we spawn our default pawn, PlayerSpawned() in our player controller
is to be called. This function spawns our companion pawns.
/*****************************************************************
* Returns a pawn of the default pawn class
* @param NewPlayer - Controller for whom this pawn is spawned
* @param StartSpot - PlayerStart at which to spawn
* pawn
* @return pawn
*****************************************************************/
function Pawn SpawnDefaultPawnFor
(Controller NewPlayer, NavigationPoint StartSpot)
{
local Pawn ResultPawn;
ResultPawn = super.SpawnDefaultPawnFor
(NewPlayer, StartSpot);
if(ResultPawn != none)
{
TutorialPlayerController(NewPlayer).PlayerSpawned
(StartSpot);
}
return ResultPawn;
}
2.
We need to tell TutorialPawn to spawn our default controller. This is actually
defined in UTPawn , but we need to place it in our PostBeginPlay() function
so that our companions spawn right as the map loads.
 
Search Nedrilad ::




Custom Search