Page 1 of 2 12 LastLast
Results 1 to 40 of 44
  1. #1
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default Attaching Staticmeshes to Player?

    Can you attach Staticmeshes to the player? Note I don't mean Skeletalmeshes, that's a different beast (as in the attachment classes). What I'm trying to do is: I've spawned a custom staticmesh in-game and I want to attach it to my character.

    I know in the editor you can Base one mesh on another, but I can't figure out anything similar looking through the code. Any example class or if anyone outright knows the function(), it would be appreciated!

    danimal

  2. #2
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Location
    Sydney, Australia
    Posts
    35
    Gamer IDs

    Gamertag: Chrustec

    Default

    hmmm, for one static meshes don't move, they are static. You'd want to look at using an InterpActor for this (a dynamic mesh) If this is a piece of Armour or something then maybe it needs to have some sort of ref node attached to the player mesh prior to export and then using unrealscript tell the mesh type to attach to that ref node - or perhaps you could have those pieces already attached to the character but hidden when the character spawns and then use unreal script to toggle them from a bHidden state (I couldn't say how to do this at this time as I am not sure myself but might be some food for thought) I would look into ref nodes and multiple objects for export through ActorX as a starting point though. I hope this helps ya out

  3. #3
    MSgt. Shooter Person
    Join Date
    Jan 2006
    Location
    Madrid, Spain
    Posts
    173

    Default

    To attach any generic actor to another:
    Code:
    AttachedActor.SetBase(RootActor);

  4. #4
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    Wewt thank you! Yes I know what static means, it's sort of why I would prefer using them over skeletalmeshes with a physics asset tbh. Appreciate the responses, off to try Xaklse's suggestion.

    danimal

  5. #5

    Default

    This is a very good thing to be able to do since it is how you will allow the player to pick up objects in the world to manipulate them. Like picking up a light crate and moving it on top of something else to help you jump to reach something up high etc.

  6. #6
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,509

    Default

    If you wish to just attach a static mesh onto a skeletal component on either bones or sockets, then use the relevant AttachComponent functions instead. It's wasteful on resources to attach actors when just attaching components would do.

    In my game, I am currently just creating new StaticMeshComponent's or SkeletalMeshComponent's and then attaching them onto the player's SkeletalMeshComponent because I only required the visuals.

  7. #7
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    Well because I'm sadistic, I'm trying to attach a Constrained actor to my player. Who knows if this will ever work. I may have to just do it Whizzle style and create my own player not based off of a Pawn.

    I sort of don't understand components, where do they fit in the world of bones and sockets?

    Artist trying to code is always sort of laughable, am I in the ballpark?

    danimal
    Last edited by danimal'; 11-11-2009 at 08:26 PM.

  8. #8
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,509

    Default

    Components in this case StaticMeshComponent and SkeletalMeshComponent. They represent the mesh rendering side of things. In older versions of Unreal Engine, these used to be bound with Actor's directly (and you switched between different modes of rendering an actor). In Unreal Engine 3, a component method was used so that an actor could control specifically how it wanted to be rendered. If you need sprites together with a skeletal mesh you just added those components in.

    Bones in SkeletalMeshes are sort of self explanatory. Sockets is effectively a defined point that is relative to a skeletal mesh bone. Sockets can have a name which makes them easier to use as well. It makes code a little more stream lined as I could just say "Attach this weapon on the LeftHand socket" and then let the artist decide where the LeftHand socket is actually located on the skeletal mesh.

    Component based design is similar to Unity in this regard, although I should say Unity is like UE3 since UE3 came out before Unity

  9. #9
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    Well you tried! A bit beyond me, I'll go dig around documentation to try to understand better. Mind giving a super simple example of how using the AttachComponent system you would attach ItemX to PlayerY? I learn mostly by example myself. Appreciate the response.

    danimal

  10. #10
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,509

    Default

    If you have UT3, try looking up the UTWeaponAttachment stuff. That one is a pretty classic example.

  11. #11
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    I'm seriously not getting something. I spawn something like so:
    Code:
    Hook = Spawn(class'MyMod.GrappleHook', , '', Instigator.Location);
    It happily spawns wherever I am at the moment, makes sense. I then want to attach the bloody thing to my player. I try to do something like:
    Code:
    Hook.SetBase(UTPlayerController);
    It compiles, doesn't complain at me (like if I tried attaching it to a Pawn), but does absolutely nothing. What am I doing wrong? All I want to do is spawn my custom class and attach it to my player :/

    danimal

  12. #12

    Default

    Have you tried attaching it to the Pawn? iirc the PlayerControllers (the actual actors) don't follow the Pawns around.

  13. #13
    MSgt. Shooter Person
    Join Date
    Nov 2007
    Location
    Cambridge, UK
    Posts
    253
    Gamer IDs

    Gamertag: TheSchizoslayer

    Default

    Quote Originally Posted by danimal' View Post
    I'm seriously not getting something. I spawn something like so:
    Code:
    Hook = Spawn(class'MyMod.GrappleHook', , '', Instigator.Location);
    It happily spawns wherever I am at the moment, makes sense. I then want to attach the bloody thing to my player. I try to do something like:
    Code:
    Hook.SetBase(UTPlayerController);
    It compiles, doesn't complain at me (like if I tried attaching it to a Pawn), but does absolutely nothing. What am I doing wrong? All I want to do is spawn my custom class and attach it to my player :/

    danimal
    The PlayerController doesn't move around. You want to attach it to the Pawn which is the physical representation of the player.

  14. #14
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    Yah I've tried this, still nothing. Is it because the thing I'm trying to attach is a KAsset? To be clear, I made a custom KAsset (which has a skeletal mesh), and am trying to attach it to my character (a derivative of UTPawn). In brief:

    Custom KAsset (just using the flag for now to ensure it's not a mesh problem on my end):
    Code:
    class GrappleHook extends KAssetSpawnable
    
    DefaultProperties
    {
    	Begin Object Name=KAssetSkelMeshComponent
    		Animations=None
    		SkeletalMesh=SkeletalMesh'CTF_Flag_IronGuard.Mesh.S_CTF_Flag_IronGuard'
    		PhysicsAsset=PhysicsAsset'CTF_Flag_IronGuard.Mesh.S_CTF_Flag_IronGuard_Physics'
    		bHasPhysicsAssetInstance=true
    	End Object
    }
    From my weapon:
    Code:
    Hook = Spawn(class'MyMod.GrappleHook', , '', Instigator.Location);
    Hook.SetBase(Instigator);
    It spawns the flag (again I'm just using it as a placeholder), but absolutely positively does not attach it. I've tried UTPawn, Owner, Instigator, etc etc, it compiles fine but never attaches it. Argh?! What am I doing wrong :/

    danimal
    Last edited by danimal'; 11-12-2009 at 04:42 PM.

  15. #15
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    Bumpity b/c I just edited my previous response, should have put it down here I've tried Pawn (see post directly above), it doesn't seem to work :/

    danimal

  16. #16
    Iron Guard
    Join Date
    Nov 2007
    Location
    USA
    Posts
    659

    Default

    Have you tried attachComponent ?

  17. #17
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    Quote Originally Posted by mikepurvis View Post
    Have you tried attachComponent ?
    Yah, but I'm not sure I understand how to use it properly. My KAsset has a component (KAssetSkelMeshComponent) in the default properties (see above), but I'm not sure I'm using the syntax right from inside the weapon after I spawn it. I tried
    Code:
    UTPawn.AttachComponent(Hook.KAssetSkelMeshComponent)
    and a few other variations, but the compiler yells at me that I make no sense :/

    Can you give an example of the proper syntax/format? I wouldn't think attaching something to the player would be this taxing :/ And I still don't understand why Base isn't working for me. Sigh!

    danimal

  18. #18
    Redeemer
    Join Date
    Mar 2009
    Posts
    1,040

    Default

    For any poor soul who tries to do this, this is what I *finally* figured out about attaching skeletal meshes to the player (pawn):

    Define up top in your class:
    Code:
    var SkeletalMeshComponent yourmesh;
    //"yourmesh" just serves as a reference to SkeletalMeshComponent
    Then call during your function:
    Code:
    Pawn.mesh.AttachComponent(yourmesh, 'bone_name_here');
    //note for me since I'm calling from my gun, I actually use:
    //Instigator.mesh.AttachComponent(yourmesh, 'b_Spine');
    //In english we're saying: attach to the mesh of my pawn, the thing we defined as "yourmesh", at the //bone named 'b_Spine' on the player mesh
    Down below in your default properties:
    Code:
    //this is where we're going to create the component itself as shown below (this wasn't intuitive to me //that we're essentially creating the component simply by defining it in the defaults)
    //we're also going to define what skeletal mesh we want to attach to our player
    defaultproperties
    {
       Begin Object class=SkeletalMeshComponent name=attachMesh
    		SkeletalMesh=SkeletalMesh'Your_Mesh_Reference_Here'
       End Object
       yourMesh=attachMesh
    }
    The huge mistake I made was that I thought about it wrong. I was trying to spawn a mesh with Spawn() and then to attach it. That's completely wrong, there's no spawning involved. All you do is create the component (in default properties), define the mesh you want to attach, then use the above string to actually call it in a function. Hopefully this prevents someone else spending the inordinate amount of time I did :/

    danimal
    Last edited by danimal'; 11-14-2009 at 03:43 AM.

  19. #19

    Default

    Can I use AttachComponent(yourmesh, 'bone_name_here'); with an Actor instead of a Pawn?

  20. #20
    Veteran
    Join Date
    Dec 2003
    Location
    Finland
    Posts
    5,996

    Default

    Bump. So to be certain, I just need to declare a new StaticMeshComponent in default properties, then assign it to a component variable and then attach it in PostBeginPlay or some such?

    How can I get random rotations and overlay meshes which align correctly?
    Also known as Rask — http://www.ottorask.com/

    UT3 Levels: CTF-Austere (MSU P3 5th place)
    UE3 Tutorials: From Textures To Materials In UE3 Complex Fire In UE3

  21. #21
    MSgt. Shooter Person
    Join Date
    Jan 2010
    Posts
    42

    Default

    Quote Originally Posted by pk3 View Post
    Can I use AttachComponent(yourmesh, 'bone_name_here'); with an Actor instead of a Pawn?
    Yes, at least it worked for me on KActorSpawnable object.
    The only issue I can't resolve is that attached component is an SkeletalMesh with specified physics set, collision works but bones dosn't move. So it behaives as a static mesh rather than a skeletal.

  22. #22
    Prisoner 849
    Join Date
    Aug 2008
    Posts
    993

    Default

    so if you want to attach a mesh it has to be skeletal?
    your code has worked for me - i used the flag thing too

    but now im trying to change it for a static mesh, with not much luck

    (edit)
    yes you can, never mind
    thanks danimal! =)
    Last edited by axelzellalex; 06-23-2010 at 08:38 PM.

  23. #23

    Default

    Just made a Creating a malee system in UDK's Kismet. Also a creating enemy pawns as well, to follow and attack.

    UDK Tutorial Malee Attack in Kismet Part1
    http://www.youtube.com/watch?v=rM7EbIC42VE

    UDK Tutorial Malee Attack in Kismet Part1
    http://www.youtube.com/watch?v=-gX9KCEVHOk

    UDK Tutorial Finishing Malee Attack And Starting Enemies in Kismet

    http://www.youtube.com/watch?v=PKycVeGGikg


    My Portfolio
    http://michaeljcollinsdreamart.com
    or
    http://winwarproductions@yahoo.com

  24. #24
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    I have a similar problem, but instead of attach the spawned skeletal mesh to Player's pawn, I want to attach it to another skeletal mesh that is already attached to Pawn. That's like attach a skeletal mesh to player's weapon.

    In other words what I want to do is:

    Begin game & spawn player's pawn -> spawn weapon1 -> attach weapon1 to pawn's socket -> spawn weapon2 -> attach weapon2 to weapon1 socket

    So far, I was able to spawn and attach successfully only Weapon1, while I've lot of problems with Weapon2.

    That's what I tried:

    In MyPawn.uc
    Code:
    function AddDefaultInventory()
    {
    
    	Weapon1=Spawn(class'MYWeapon1,self);
    	Weapon1.AttachWeaponTo(Mesh, Weapon_socket1);
    
    	Weapon1.AddSecondWeapon();
    
    }
    In Weapon1.uc
    Code:
    class MYWeapon1 extends MYWeapon1Group;
    
    
    var MYWeapon2 Weapon2;
    var name Weapon_socket2;
    
    function AddSecondWeapon()
    {
    
    	Weapon2=Spawn(class'MYWeapon2',self);
    	//Weapon2.AttachWeaponTo(Mesh, Weapon_socket2);
    
     /*When I try to use AttachWeaponTo function it returns me a type mismatching error in parameter 1 (I don't get why though), so I went to an AttachComponentToSocket instead*/
    
    	Weapon2.AttachComponentToSocket(Mesh, Weapon_socket2);
    
    }
    In MYWeapon2Group.uc
    Code:
    class MYWeapon2Group extends UDKWeapon;
    
    var name Weapon2AttachmentSocketName;
    
    function AttachComponentToSocket(ActorComponent Component, name SocketName)
    {
    	
    	local MYWeapon1 V;
    
    	V = MYWeapon1(Instigator.Weapon);	
    
    /*Here is where the problem is...
    whatever of the following lines I use, it returns the error "Unrecognized AttachComponentToSocket in class MYWeapon2"*/
               //V.Mesh.AttachComponentToSocket(Mesh,Weapon2AttachmentSocketName);
    	Component.AttachComponentToSocket(Mesh,Weapon2AttachmentSocketName);
    
    }
    DefaultProperties
    {
               Begin Object Class=SkeletalMeshComponent Name=SkeletalMeshComponent1
    		CollideActors=false
    		AlwaysLoadOnClient=true
    		AlwaysLoadOnServer=true
    		bUseAsOccluder=FALSE
    		bUpdateSkelWhenNotRendered=false
    		bIgnoreControllersWhenNotRendered=true
    		bOverrideAttachmentOwnerVisibility=true
    		bAcceptsDynamicDecals=FALSE
    	
    	End Object
    
    
    	Components.Add(SkeletalMeshComponent1)
    	Mesh=SkeletalMeshComponent1
    
    	Weapon2AttachmentSocketName=Weapon_socket2
    }
    I could easily solve this problem attaching Weapon2 directly to player's pawn, but that's not what I want.
    Any idea?
    Last edited by Alfier; 01-28-2011 at 05:02 AM.

  25. #25
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Sorry for bump but I need to solve this problem asap

  26. #26
    Iron Guard
    Join Date
    Sep 2009
    Location
    England
    Posts
    733

    Default

    The error messages are quite explicit.

    You get a type mismatch because you're not passing the proper kind of parameter. Look at the function's declaration and see what kind of value you need to pass.

    The second error means you're calling a function on a object that doesn't define the said function. Look at where this function is defined.

    I can't tell you as I don't have access to my code right now.
    Knowledge should be shared with everyone. Technique however, is your own thing.

    My UnrealScript Lessons
    My Blog

    I'm working full-time, so I'm not available for freelance work, sorry.

  27. #27
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Quote Originally Posted by Mougli View Post
    You get a type mismatch because you're not passing the proper kind of parameter. Look at the function's declaration and see what kind of value you need to pass.
    Yes, the function wants a SkeletalMeshComponent to be passed, but what I'm passing is the skeletal mesh component of my custom weapon class, so I don't know what's wrong...

    For the second error, it says that i'm calling a function on a object that doesn't define the said function, but the object is a subclass of UDKWeapon. That means UDKWeapon doesn't have an AttachComponentToSocket function? And if it's the case, what and where should I put this function?

  28. #28
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    AttachComponentToSocket is in the SkeletalMeshComponent
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  29. #29
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Quote Originally Posted by Blade[UG] View Post
    AttachComponentToSocket is in the SkeletalMeshComponent
    Ok, thank you, but unfortunately I'm dumb and still can't think of a way to solve the problem...

    It's enough to copy and past
    Code:
    native final function AttachComponentToSocket(ActorComponent Component, name SocketName);
    from SkeletalMeshComponent.uc to my custom class?

  30. #30
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    No, you need to call the function IN the Weapon Mesh.

    if your Weapon's Mesh is stored in "Mesh", then: Mesh.AttachComponentToSocket()
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  31. #31
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Quote Originally Posted by Blade[UG] View Post
    No, you need to call the function IN the Weapon Mesh.

    if your Weapon's Mesh is stored in "Mesh", then: Mesh.AttachComponentToSocket()
    I already tried this way, and this is the error I get

    Code:
    Unrecognized member AttachComponentToSocket in class mesh component
    I tried a lot of ways, even stupid things, nothing worked...

  32. #32
    Iron Guard
    Join Date
    Sep 2009
    Location
    England
    Posts
    733

    Default

    Weapon.Mesh is a MeshComponent

    AttachComponentToSocket() is a member of SkeletalMeshComponent.

    You need to typecast Mesh into a SkeletaMeshComponent:

    SkeletalMeshComponent(Mesh).AttachComponentToSocke t()
    Knowledge should be shared with everyone. Technique however, is your own thing.

    My UnrealScript Lessons
    My Blog

    I'm working full-time, so I'm not available for freelance work, sorry.

  33. #33
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Quote Originally Posted by Mougli View Post
    Weapon.Mesh is a MeshComponent

    AttachComponentToSocket() is a member of SkeletalMeshComponent.

    You need to typecast Mesh into a SkeletaMeshComponent:

    SkeletalMeshComponent(Mesh).AttachComponentToSocke t()
    That's my code

    Code:
    function AttachComponentToSocket(ActorComponent Component, name SocketName)
    {
    	
    	local Weapon1 V;
    
    
    	V = Weapon1(Instigator.Weapon);	
    
    	V.SkeletalMeshComponent(Mesh).AttachComponentToSocket(Component,SocketName);
    		
    }
    and this is the error

    Code:
    Unrecognized member SkeletalMeshComponent in class Weapon1
    What I'm trying to do is call from class Weapon1 the function to spawn Weapon2 and attach it to Weapon1. What I'm doing wrong?

  34. #34
    Iron Guard
    Join Date
    Sep 2009
    Location
    England
    Posts
    733

    Default

    ...
    It's SkeletalMeshComponent(V.Mesh).AttachComponentToSoc ket()

    You should read that: http://udn.epicgames.com/Three/Unrea... among classes
    Knowledge should be shared with everyone. Technique however, is your own thing.

    My UnrealScript Lessons
    My Blog

    I'm working full-time, so I'm not available for freelance work, sorry.

  35. #35
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Quote Originally Posted by Mougli View Post
    ...
    It's SkeletalMeshComponent(V.Mesh).AttachComponentToSoc ket()

    You should read that: http://udn.epicgames.com/Three/Unrea... among classes
    Asd ok thank you, I simply can't remember everything I read (I remember very few of the things I read though lol). That problem is solved, but another one comes out...

    I need to attach weapon2 to weapon1, so following the code I first have to define the Weapon1 instigator, so weapon 2 can attach to.

    Code:
    simulated function AttachWeaponTo( SkeletalMeshComponent MeshCpnt, optional Name SocketName )
    {
    	
    	local Weapon1 V;
    	
    	V = Weapon1(Instigator.Weapon);
    	
    	SkeletalMeshComponent(V.Mesh).AttachComponentToSocket(MeshCpnt,SocketName);
    }
    This way I get no errors, but the code still doesn't work and in log V is marked as empty. Searching for instigator i couldn't find a way to have it to work with weapon instead of pawn...

  36. #36
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    if V is None, then Instigator.Weapon is not a Weapon1.

    There's no reason to typecast to your custom weapon here, anyway.

    Code:
    SkeletalMeshComponent(Instigator.Weapon.Mesh).AttachComponentToSocket(MeshCpnt, SocketName);
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  37. #37
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Quote Originally Posted by Blade[UG] View Post
    if V is None, then Instigator.Weapon is not a Weapon1.

    There's no reason to typecast to your custom weapon here, anyway.

    Code:
    SkeletalMeshComponent(Instigator.Weapon.Mesh).AttachComponentToSocket(MeshCpnt, SocketName);
    Still won't work Log's telling me
    Code:
    ScriptWarning: Accessed None 'Weapon'
    referring to instigator weapon


    I can't think of a reason for this...
    This is the code, I hope that someone can help me to solve this mess.
    Code:
    function AddDefaultInventory()
    {
    
    	Weapon1=Spawn(class'MYWeapon1',self);
    	Weapon1.AttachWeaponTo(Mesh, Weapon_Right);
    
    	Weapon1.AddWeapon();
    
    }
    Code:
    function AddWeapon()
    {
    	Weapon2=Spawn(class'MYWeapon2',self);
    	Weapon2.AttachWeaponTo(SkeletalMeshComponent(Mesh), Elsa_Joint);
    
    }
    Code:
    simulated function AttachWeaponTo( SkeletalMeshComponent MeshCpnt, optional Name SocketName )
    {
    	
    	super.AttachWeaponTo(MeshCpnt, SocketName);
    
    	SkeletalMeshComponent(Instigator.Weapon.Mesh).AttachComponentToSocket(MeshCpnt,SocketName);
    }

  38. #38
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    I just tried this other way

    Code:
    function AddDefaultInventory()
    {
               Weapon1=Spawn(class'MYWeapon1',self);
    	Weapon1.AttachWeaponTo(Mesh, Weapon_Right);
    
    	Weapon2=Spawn(class'MYWeapon2',self);
             if(Weapon2 != none) `log("Weapon2 SPAWNED !!!!!!");
    
    SkeletalMeshComponent(Weapon2.Mesh).AttachComponentToSocket(SkeletalMeshComponent(Weapon1.Mesh),Weapon2_Joint);
    
    }
    putting this function directly into MyPawn.uc
    Now thanks to the log I know for sure that Weapon2 has been spawned, but still it won't appear nor attach to weapon1...
    I really am stuck at this, not even this that should be the simplest way to achieve the result works...

  39. #39
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    what are you trying to attach a weapon to another weapon?
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  40. #40
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Location
    Italy
    Posts
    47
    Gamer IDs

    Gamertag: Alfier

    Default

    Quote Originally Posted by Blade[UG] View Post
    what are you trying to attach a weapon to another weapon?
    Yes, that's exactly what I want to do (I said that 10 posts ago though ). Think of it like a weapon with various interchangeable components. I need to attach weapon 2 directly to weapon 1 for the simple reason that the socket position changes from the various types of weapon 1 (into a type of weapon 1 it could be at the top, into another at the bottom).

    So are you trying to tell me that I simply can't attach a weapon to another weapon? >_< If that's so, it sucks, but I guess I can simply change the parent class of the custom weapon to attach, so it doesn't extends UDKWeapon anymore, right?

    Edit: I REALLY am a dumbass...
    Code:
    function AddDefaultInventory()
    {
    	Weapon_Right='Weapon_Right';
    	Weapon2_Joint='Weapon2_Joint';
    
    	Weapon1=Spawn(class'MYWeapon1',self);
    	Weapon1.AttachWeaponTo(Mesh, Weapon_Right);
    
    	Weapon2=Spawn(class'MYWeapon2',self);
    	Weapon2.AttachWeaponTo(SkeletalMeshComponent(Weapon1.Mesh), Weapon2_Joint);	
    
    }
    I forgot to assign value to the sockets variables, no wonder it didn't work...

    Thank you guys I really appreciate your help!
    Last edited by Alfier; 01-30-2011 at 07:41 AM.


 
Page 1 of 2 12 LastLast

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.