Results 1 to 12 of 12
  1. #1
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default Same Weapon, Different Mesh per Class

    Hello,

    Here's the basic info of my game:

    • There are 6 classes
    • There are 7 weapons
    • Each Class has a unique weapon model
    • The weapon model skin changes depending on the weapon used
    • Each weapon has 2 firing modes
    • Each class can use every weapon


    Same for example,
    Class: Berserker
    Weapon Model: Link Gun
    Skin when using Rockets: LGSkin_Red
    Skin when using Shock Balls: LGSkin_Purple

    Class: Sniper
    Weapon Model: Sniper Rifle
    Skin when using Rockets: SnipSkin_Red
    Skin when using Shock Balls: SnipSkin_Purple

    I am wondering how to implement this. I currently have a pawn for each class (Pawn_Berserker, Pawn_Sniper etc) and a weapons as different classes (Weap_Sniper, Weap_MachineGun etc). My trouble is assigning a weapon mesh to each pawn class and a skin to each weapon for each class.

    I'm finding it hard to find examples of this implemented. I assume I need to override UTInvManager function "SetPendingWeapon", but I'm not sure if I'm heading down the wrong path or not.

  2. #2
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Use AttachWeaponTo to see which Pawn own that weapon. If your weapons is extended from UTWeapon, then there is already implemented that functionality - SetSkin(UTPawn(Instigator).ReplicatedBodyMaterial) ;

  3. #3
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default

    Thanks for the reply. The problem is that the mesh of the weapon changes between the classes, not the skin. Is there a similar function to SetSkin for the weapon mesh? I've tried variations of SetSkeletalMesh, with the Mesh set in the Pawn class (eg. in my weapon class, I tried using the line "Mesh.SetSkeletalMesh(UPHPawn(Owner).WeapMesh) ;" along with "Mesh.AnimSets(0) = UPHPawn(Owner).WeapAnimSets;". I'm confused where to go from here, I feel I'm close, but can't figure out the issue.

  4. #4
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Reassuming - you want to all Pwans have the same weapon, but with different mesh? That something new...
    Last edited by VendorX; 03-12-2012 at 05:28 PM.

  5. #5
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default

    It's hard to explain, I'll try my best. If you've ever played Metroid Prime: Hunters on DS, I'm trying to remake that.

    • There are 7 classes and 8 weapons.
    • Every class can use every weapon.
    • However, the weapon mesh is different for each class.
    • The weapon skin changes for each weapon.


    I hope that explains it. If not, I can try again!

  6. #6
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Well... That's mean, that each weapon can have 7 different meshes - depend on which Pawn class have it. I'm right?

  7. #7
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default

    Yes, that's correct.

  8. #8
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Last question: from which class you extending your weapons?

  9. #9
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default

    UTWeapon currently. Can transfer to UDKWeapon if that helps at all.

  10. #10
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Nope... UTWeapon is good place. Use -like i said- AttachWeaponTo to see which Pawn will own that weapon. Now, depend on Pawn class switch mesh by calling Mesh.SetSkeletalMesh(NewMesh); and switch material by Mesh.SetMaterial(ElementIndex, Material);
    You need example ..?

    ...and do that after calling Super.

  11. #11
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default

    Hmmm, I get an error I've had before: Error, Unrecognized member 'SetSkeletalMesh' in class 'MeshComponent'

    Also, I've had a think. Do you think it's more viable to change the function "SwitchWeapon" (or whichever actually does the switching out of the weapons and deals with detaching/attaching the meshs) so that the model is never actually detached from the mesh and just change the skin when it is called? As you will always have the same weapon model for the match, I see no need to have to detach it, then re-attach and set a new skin. That way, I only need to apply the Mesh.SetSkeletalMesh(NewMesh); to the default weapon. (once I/we get it working )
    Last edited by Zaiteria; 03-12-2012 at 06:51 PM.

  12. #12
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Not tested, but should work...
    Code:
    // Global...
    var array<SkeletalMesh> MeshList[7];
    var array<MaterialInterface> MaterialList[7];
    
    simulated function AttachWeaponTo(SkeletalMeshComponent MeshCpnt, optional Name SocketName)
    {
    	Super.AttachWeaponTo(MeshCpnt, SocketName);
    
    	if (Instigator != None)
    	{
    		Switch( Instigator.Class )
    		{
    			case class'MyPawnClass0': ChangeWeaponDef(MeshList[0], MaterialList[0]); break;
    			case class'MyPawnClass1': ChangeWeaponDef(MeshList[1], MaterialList[1]); break;
    			case class'MyPawnClass2': ChangeWeaponDef(MeshList[2], MaterialList[2]); break;
    			case class'MyPawnClass3': ChangeWeaponDef(MeshList[3], MaterialList[3]); break;
    			case class'MyPawnClass4': ChangeWeaponDef(MeshList[4], MaterialList[4]); break;
    			case class'MyPawnClass5': ChangeWeaponDef(MeshList[5], MaterialList[5]); break;
    			case class'MyPawnClass6': ChangeWeaponDef(MeshList[6], MaterialList[6]); break;
    			default:
    				`warn("Invalid Pawn class");
    		}
    	}
    }
    
    simulated function ChangeWeaponDef(SkeletalMesh NewMesh, optional MaterialInterface NewMaterial, optional int ElementIndex)
    {
    	if( Mesh != None )
    	{
    		if( NewMesh != None )
    			Mesh.SetSkeletalMesh( NewMesh );
    
    		if( NewMaterial != None )
    			Mesh.SetMaterial( ElementIndex, NewMaterial );
    	}
    }
    BTW. Don't forget about UTWeaponAttachment...
    Last edited by VendorX; 03-12-2012 at 07:01 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.