Results 1 to 21 of 21
  1. #1
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default How to set different pawns for different characters in game?

    So I have a pawn for my bots, and a pawn for my player. I also have an AI controller for my bots and a PlayerController for my player. When I hit the "Play in View Port" button (alt+F8) what I get is all my bots working well and dandy but I too am the pawn that the bots use, this is because I set the DefaultPawnClass to my bot pawn.

    So my question is simply, where/how do I notify the game that my player pawn is not the same as the default pawn. Where do I put the code for a particular player to be a particular pawn? In the end I will have something like 10 players in a game and there will be a character selection screen so I am trying to figure out how to create different characters for players to choose from.

    Thanks in advance!

  2. #2
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    I don't know if this was the wrong place to put this or what but someone has to know how to manipulate pawns? Should I post this under characters and animation?

  3. #3
    MSgt. Shooter Person
    Join Date
    Feb 2008
    Location
    Pittsburgh, Pennsylvania
    Posts
    301
    Gamer IDs

    Gamertag: IrishKilter

    Default

    Pawn's all have a variable inside their code labeled "Mesh". This Mesh is what the pawn's look like, if you want to change that inside your Pawn's default property's you assign Mesh to a new one, however you can't just assign a mesh, you have ot creat it first, to do that inside your defaultproperties of the pawn you use a Begin Object (basically says, Create!) and assign it information. Here is your example:

    Code:
    Begin Object Class=SkeletalMeshComponent Name=Pawn_PlayerBaseSkelMeshComp
            SkeletalMesh=SkeletalMesh'CH_Sullivan.Mesh.Sullivan_RegularOutfit' //This is your model here!
            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)
    	bOverrideAttachmentOwnerVisibility=true
    	bAcceptsDynamicDecals=FALSE
    	bHasPhysicsAssetInstance=true
    	bEnableFullAnimWeightBodies=true
    	TickGroup=TG_PreAsyncWork
    	MinDistFactorForKinematicUpdate=0.2
    	bChartDistanceFactor=true
            RBDominanceGroup=16
    	Scale=1.0
              End Object
    
      Mesh=Pawn_PlayerBaseSkelMeshComp
      Components.Add(Pawn_PlayerBaseSkelMeshComp)
    Now you can take the first line inside it (SkeletalMesh=) and assign a mesh from the editor by right clicking your Skeletal Mesh in the editor and hitting Copy Reference or something similiar, then past that entire line right after the = sign.

  4. #4
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    Thanks for your response.

    I think I understand the concept of changing characteristics of a pawn, my question is how to I set that pawn as the one to use for a player (or bot). When I click play, it selects the wrong pawn basically. How would I set 5 different players to 5 different pawns?

  5. #5
    Iron Guard
    Join Date
    Jan 2011
    Location
    Netherlands
    Posts
    738
    Gamer IDs

    Gamertag: ColdGuy

    Default

    Quote Originally Posted by anomaly_a View Post
    Thanks for your response.

    I think I understand the concept of changing characteristics of a pawn, my question is how to I set that pawn as the one to use for a player (or bot). When I click play, it selects the wrong pawn basically. How would I set 5 different players to 5 different pawns?
    just make different pawn classes

  6. #6
    MSgt. Shooter Person
    Join Date
    Jul 2006
    Location
    NC
    Posts
    101

    Default

    Take a look in UTPawn.uc, looking for SetCharacterClassFromInfo( )... or you could probably call SetCharacterMeshInfo( ) directly, or even Mesh.SetSkeletalMesh( ) if you want to set the materials manually (or if you're not extending UTPawn).
    Last edited by Geist; 09-02-2011 at 09:58 PM.
    "Blah!"
    -- Unknown

  7. #7
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    Hmmm I stated in my post that I have made multiple pawn classes. I want to know how to set those pawn classes for different players, I understand how to change the meshes and such in the pawn, but i have 3 pawns and don't know where to tell the game I want to use them.

  8. #8
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    I think what I am gathering is that this is a lot harder to do then I thought it was. I had assumed there was a way to set any characters pawn from a list of pawns and that the pawn stored all the information for different characters (one pawn runs faster, or has different abilities).

    Is it more along the lines of you have a pawn class and you just changed it during run time to meet the requirements of the character? If you select a different character it just changes their inventory and runspeed rather then swapping out an entire pawn?

  9. #9
    Marrow Fiend

    Join Date
    Jul 2006
    Location
    WorldInfo_61
    Posts
    4,198
    Gamer IDs

    Gamertag: KickedWhoCares

    Default

    If you search for where DefaultPawnClass is used you can filter bots from humans using a cast of the controller like so:

    Code:
    if(AIController(Controller) != none){
    	//This is a bot
    	defaultPawnClass=class'yourbotpawn';
    }else{
    	//This is a human
    	defaultPawnClass=class'yourhumanpawn';
    }

  10. #10
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    Yeah, that is helpful but it's only really step one of what I was hoping for. This would cause all the bots to be a certain pawn and all the players to be another. I was hoping for a different Pawn for each player, but this might not be how it was intended. It seems like most people think it should just be a change of properties to the pawn depending on which character was picked. Am I right in this assumption?

  11. #11

  12. #12
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    I got it working I think. Heres what I did:

    My player controller class:

    Code:
    class MyPlayerController extends UTPlayerController;
    
    var int team;
    
    simulated function PostBeginPlay()
    {
    	super.PostBeginPlay();
    	local PlayerPawn0 NewPlayer;
    	NewPlayer = Spawn(class'PlayerPawn0');
    	super.Possess(NewPlayer, false);
    	team = 0;	
    }
    
    function int getMyTeam()
    {
    	return team;
    }
    
    
    DefaultProperties
    {
    }
    and my pawn class:

    Code:
    class PlayerPawn0 extends UTPawn
    	placeable;
    
    var int team;
    
    simulated event PostBeginPlay()
    {
    	super.PostBeginPlay();
    	team = 0;
    }
    
    function int getMyTeam()
    {
    	return team;
    }
    
    DefaultProperties
    {
    	Begin Object Name=CollisionCylinder
    		CollisionHeight=+44.000000
        	end object
        	bJumpCapable=true
        	bCanJump=true
        	GroundSpeed=300.0	
    }
    So this pawn can jump and runs faster then my bot pawn. Also I give them different inventories. At some point I will work on setting the pawn in game or at a menu or something.

  13. #13

  14. #14
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    Hmmmm I guess you're right, so what is the solution. There has to be a way for there to be different characters in a game.

  15. #15
    Marrow Fiend

    Join Date
    Jul 2006
    Location
    WorldInfo_61
    Posts
    4,198
    Gamer IDs

    Gamertag: KickedWhoCares

    Default

    There is! You use UTFamilyInfo, to set pawn defaults hook SetPlayerDefaults in your GameInfo and assign them through a static function in your UTFamilyInfo subclass. Its exactly the same as the species code in UT2004.

  16. #16
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    I only understood about half of that, you mind if i send you a private message for some additional details?

  17. #17
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    There is a way to set different bots as different pawns in kismet. Are kismets capabilities based on the capabilities of unreal script? If so you should be able to set different pawns for each instance of a player. Along those lines is there a way in kismet to set the pawn of a players (not a bot, I already know that can be done).

  18. #18
    Marrow Fiend

    Join Date
    Jul 2006
    Location
    WorldInfo_61
    Posts
    4,198
    Gamer IDs

    Gamertag: KickedWhoCares

    Default

    Keep the posts on here please then anyone can view them later and the PM boxes are tiny.

    Code:
    class mGame extends UTDeathmatch;
    	dependson(mFamilyInfo);
    
    var class<UTFamilyInfo> DefaultFamily;
    
    function SetPlayerDefaults(Pawn PlayerPawn)
    {
    	local class<UTFamilyInfo> FamilyC;
    
    	FamilyC = UTPawn(PlayerPawn).GetFamilyInfo();
    	if(class<mFamilyInfo>(FamilyC) != None)
    		class<mFamilyInfo>(FamilyC).static.SetPlayerDefaults(PlayerPawn);
    
    	PlayerPawn.AirControl = PlayerPawn.Default.AirControl;
    	PlayerPawn.GroundSpeed = PlayerPawn.Default.GroundSpeed;
    	PlayerPawn.WaterSpeed = PlayerPawn.Default.WaterSpeed;
    	PlayerPawn.AirSpeed = PlayerPawn.Default.AirSpeed;
    	PlayerPawn.Acceleration = PlayerPawn.Default.Acceleration;
    	PlayerPawn.AccelRate = PlayerPawn.Default.AccelRate;
    	PlayerPawn.JumpZ = PlayerPawn.Default.JumpZ;
    /*	if ( BaseMutator != None )
    		BaseMutator.ModifyPlayer(PlayerPawn);*/
    	PlayerPawn.PhysicsVolume.ModifyPlayer(PlayerPawn);
    }
    
    function AddDefaultInventory(Pawn PlayerPawn)
    {
    	local class<inventory> inv;
    	local class<UTFamilyInfo> FamilyC;
    	local UTFamilyInfo Family;
    
    	FamilyC = UTPawn(PlayerPawn).GetFamilyInfo();
    	if(FamilyC != None)
    	{
    /*		foreach mFamilyInfo(FamilyC).FamilyInventory(inv)
    			if(PlayerPawn.InventoryMgr.FindInventoryType(inv) == None)
    				PlayerPawn.InventoryMgr.CreateInventory(inv);*/
    		Family = new(PlayerPawn) FamilyC;
    		if(mFamilyInfo(Family) != None)
    		{
    			foreach mFamilyInfo(Family).FamilyInventory(inv)
    				if(PlayerPawn.InvManager.FindInventoryType(inv) == None)
    					PlayerPawn.InvManager.CreateInventory(inv);
    		}
    	}
    	else
    	{
    		foreach DefaultInventory(inv)
    			if(PlayerPawn.InvManager.FindInventoryType(inv) == None)
    				PlayerPawn.InvManager.CreateInventory(inv);
    	}
    	PlayerPawn.Controller.ClientSwitchToBestWeapon();
    //	PlayerPawn.AddDefaultInventory();
    }
    Code:
    class mFamilyInfo extends UTFamilyInfo;
    	
    var float	AirControl,
    			GroundSpeed,
    			WaterSpeed,
    			AirSpeed,
    			Acceleration,
    			AccelRate,
    			JumpZ,
    			DodgeSpeed,
    			DodgeSpeedZ;	
    
    var array< class<Inventory> > FamilyInventory;
    
    static function SetPlayerDefaults(Pawn P)
    {
    //	if(SkeletalMesh(P.Mesh) != none)
    //		SkeletalMesh(P.Mesh) = default.CharacterMesh;
    
    	if(UTPawn(P) != none)
    		UTPawn(P).SetCharacterMeshInfo(default.CharacterMesh, default.BaseMICParent, default.BaseMICParent);
    
    	P.AirControl = default.AirControl;
    	P.GroundSpeed = default.GroundSpeed;
    	P.WaterSpeed = default.WaterSpeed;
    	P.AirSpeed = default.AirSpeed;
    	//P.Acceleration = default.Acceleration;
    	P.AccelRate = default.AccelRate;
    	P.JumpZ = default.JumpZ;
    	UTPawn(P).DodgeSpeed = default.DodgeSpeed;
    	UTPawn(P).DodgeSpeedZ = default.DodgeSpeedZ;
    }
    
    defaultproperties
    {
    	GroundSpeed=350.0	//440.0
    	AirSpeed=380.0		//440.0
    	WaterSpeed=220.0
    	DodgeSpeed=450.0		//600.0
    	DodgeSpeedZ=245.0	//295.0
    	AccelRate=1024.0
    	JumpZ=322.0
    }

  19. #19
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    And so using this method you could have says 10 different characters with different speeds, health, mana etc, just by checking maybe what character it is and then setting the stats for that character?

  20. #20
    MSgt. Shooter Person
    Join Date
    May 2011
    Posts
    74

    Default

    So if I understand this correctly, this would allow you to set the properties of the any give pawn to the values provided in the FamilyInfo. But unlike my method, it would not change the properties of the pawn for all instances of that pawn in the game?

    Are you sure my method wont work? If each person selects at a menu which character they want, and it spawned each of the corresponding pawns into the game and for each of them they possessed their pawn, you think it would be the case that the last pawn spawned would be the one that every player was playing?
    Last edited by anomaly_a; 10-26-2011 at 09:24 PM.

  21. #21

    Default

    We're doing a very similar thing. I made a base pawn with our special abilities that all characters should have (sprinting and regenerating armour) and I was going to extend these to the other custom pawns for our classes. The FamilyInfo route seems like it might be easier though.

    I'm still a little unclear as how to implement this though. Presumably the character would be selected from some sort of menu and then that value would be assigned to a variable so that when you spawn you'll have the correct family with the correct attributes. Where do these scripts actually receive the player selection of which pawn to use? For testing I don't even mind just assigning it to a key press, but I need to know where the value should be passed.

    I'm still pretty green at scripting, but I've got our custom gameinfo, playercontroller, and base pawn created with unique abilities.
    Can anyone shed some more light on this for me?

    Thanks very much
    Last edited by Pike; 12-30-2011 at 11:24 PM.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.