
Originally Posted by
bobtheturtle
Hi, I have been looking through tut's online all week, and cant find one that will work. I have a tiny ball character with 3 bones, and one animation. I imported it into UDK and set up his material,anim set, etc... Now I want that "ball" character to be controllable.
So far i have
+EditPackages=MyMod
in the config/default engine.
then in the below directory
C:\UDK\UDK-2011-12\Development\Src\MyMod\Classes
I have two files one
for player controller and one for game type.
"CustomGameType"
"playercontroller"
some example code would be great! Extending it from UT would work for me.
If you could help me with this, you would be a huge help
thank you for your time
Code:
class LexGame extends UTGame
config(Game);
var LexPlayerController currentPlayer;
function RestartPlayer(Controller aPlayer)
{
super.RestartPlayer(aPlayer);
`Log("Player restarted");
currentPlayer = LexPlayerController(aPlayer);
currentPlayer.resetMesh();
currentPlayer.rSetBehindView(true);
currentPlayer.rSetCameraMode('ThirdPerson');
}
simulated function PostBeginPlay() {
local UTGame Game;
Super.PostBeginPlay();
Game = UTGame(WorldInfo.Game);
if (Game != None)
{
Game.PlayerControllerClass=Class'LexLuthor.LexPlayerController';
}
}
defaultproperties
{
HUDType=class'UTGame.UTHUD'
PlayerControllerClass=class'lexLuthor.LexPlayerController'
ConsolePlayerControllerClass=class'UTGame.UTConsolePlayerController'
DefaultPawnClass=class'LexPawn'
PlayerReplicationInfoClass=class'UTGame.UTPlayerReplicationInfo'
GameReplicationInfoClass=class'UTGame.UTGameReplicationInfo'
DeathMessageClass=class'UTDeathMessage'
PopulationManagerClass=class'UTPopulationManager'
BotClass=class'UTBot'
bAllowKeyboardAndMouse=true
bRestartLevel=False
bDelayedStart=True
bTeamScoreRounds=false
bUseSeamlessTravel=true
bWeaponStay=true
bAutoNumBots=false
CountDown=4
bPauseable=False
EndMessageWait=1
DefaultMaxLives=0
DefaultInventory(0)=class'UTWeap_LinkGun'
//VictoryMessageClass=class'UTGame.UTVictoryMessage'
// Voice is only transmitted when the player is actively pressing a key
bRequiresPushToTalk=true
bExportMenuData=true
SpawnProtectionTime=+2.0
SpeechRecognitionData=SpeechRecognition'SpeechRecognition.Alphabet'
LastEncouragementTime=-20
MidgameScorePanelTag=DMPanel
bMidGameHasMap=false
MaxPlayersAllowed=20
//bGivePhysicsGun=true
SpreeStatEvents.Add(SPREE_KILLINGSPREE)
SpreeStatEvents.Add(SPREE_RAMPAGE)
SpreeStatEvents.Add(SPREE_DOMINATING)
SpreeStatEvents.Add(SPREE_UNSTOPPABLE)
SpreeStatEvents.Add(SPREE_GODLIKE)
SpreeStatEvents.Add(SPREE_MASSACRE)
}
Code:
class LexPawn extends UTPawn;
// members for the custom mesh
var SkeletalMesh defaultMesh;
var MaterialInterface defaultMaterial0;
var AnimTree defaultAnimTree;
var array<AnimSet> defaultAnimSet;
var AnimNodeSequence defaultAnimSeq;
var PhysicsAsset defaultPhysicsAsset;
//Hud variables for health bar
var float ElapsedRegenTime;
var float RegenAmount;
var float RegenTime;
event Tick(float DeltaTime)
{
//calculate elapsed time
ElapsedRegenTime += DeltaTime;
//has enough time elapsed?
if(ElapsedRegenTime >= RegenTime)
{
//heal the Pawn and reset elapsed time
HealDamage(RegenAmount, Controller, class'DamageType');
ElapsedRegenTime = 0.0f;
}
}
simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info)
{
Mesh.SetSkeletalMesh(defaultMesh);
Mesh.SetMaterial(0,defaultMaterial0);
Mesh.SetPhysicsAsset(defaultPhysicsAsset);
Mesh.AnimSets=defaultAnimSet;
Mesh.SetAnimTreeTemplate(defaultAnimTree);
}
exec function SetSpeed( int speed )
{
GroundSpeed = speed;
}
defaultproperties
{
//set defaults for regeneration properties
RegenAmount=2
RegenTime=1
GroundSpeed=420
Begin Object Name=WPawnSkeletalMeshComponent
SkeletalMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA'
PhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics'
bCacheAnimSequenceNodes=FALSE
AlwaysLoadOnClient=true
AlwaysLoadOnServer=true
bOwnerNoSee=false
CastShadow=true
BlockRigidBody=TRUE
bUpdateSkelWhenNotRendered=false
bIgnoreControllersWhenNotRendered=TRUE
bUpdateKinematicBonesFromAnimation=true
bCastDynamicShadow=true
RBChannel=RBCC_Untitled3
RBCollideWithChannels=(Untitled3=true)
LightEnvironment=MyLightEnvironment
bOverrideAttachmentOwnerVisibility=true
bAcceptsDynamicDecals=FALSE
AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
bHasPhysicsAssetInstance=true
TickGroup=TG_PreAsyncWork
MinDistFactorForKinematicUpdate=0.2
bChartDistanceFactor=true
bSkipAllUpdateWhenPhysicsAsleep=TRUE
RBDominanceGroup=20
Scale=0.95
bAllowAmbientOcclusion=false
}
Code:
class LexPlayerController extends UTPlayerController;
// members for the custom mesh
var SkeletalMesh defaultMesh;
var MaterialInterface defaultMaterial0;
var AnimTree defaultAnimTree;
var array<AnimSet> defaultAnimSet;
var AnimNodeSequence defaultAnimSeq;
var PhysicsAsset defaultPhysicsAsset;
simulated function PostBeginPlay() {
super.PostBeginPlay();
SetCameraMode('ThirdPerson');
resetMesh();
}
// Sets the Pawns Mesh to the resources speced in the DefaultProperties
public function resetMesh(){
self.Pawn.Mesh.SetSkeletalMesh(defaultMesh);
self.Pawn.Mesh.SetMaterial(0,defaultMaterial0);
self.Pawn.Mesh.SetPhysicsAsset(defaultPhysicsAsset );
self.Pawn.Mesh.AnimSets=defaultAnimSet;
self.Pawn.Mesh.SetAnimTreeTemplate(defaultAnimTree );
}
// Called at RestartPlayer by GameType
public function rSetBehindView(bool view){
SetBehindView(view);
}
// Called at RestartPlayer by GameType
public function rSetCameraMode(name cameraSetting){
SetCameraMode(cameraSetting);
}
DefaultProperties
{
Name="Default__LexPlayerController"
defaultMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA'
defaultAnimTree=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
defaultAnimSet(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale'
defaultPhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics'
}
This is for a third person game with regenerating health
The classes folder needs to be called LexLuthor too unless you change it in the code !
Bookmarks