Results 1 to 34 of 34
  1. #1
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default Attatching Particle System to Skel Mesh

    Howdy folks,

    alright, so ive got a Flaming Torch working ingame as a wep that does nothing (other than plays idle) and ive got a light attatched to it via the script below.

    what I need to know is how to attach my particle system via the same script. Ive had a look around at the UDN and unrealwiki and couldnt find much of use, and theres 1 archived post here that wasnt overly helpful.

    Code:
    //D6 Torch Light
    
    class UTWeap_D6_TorchLight extends UTWeap_D6_Torch;
    
    var Color LightColor;
    var float LightScale;
    var SpotLightComponent LightAttachment;
    
    simulated function PostBeginPlay()
    {
    LightAttachment = new(self)class'SpotLightComponent';
    LightAttachment.SetLightProperties(LightScale, LightColor);
    LightAttachment.CastDynamicShadows = true;
    LightAttachment.SetEnabled(true);
    LightAttachment.InnerConeAngle = 0;
    LightAttachment.OuterConeAngle = 360;
    LightAttachment.Radius = 710.0;
    LightAttachment.FalloffExponent = 5;
    if ( LightAttachment != None )
    
    {
    SkeletalMeshComponent(Mesh).AttachComponentToSocket(LightAttachment,MuzzleFlashSocket);
    //SkeletalMeshComponent(Mesh).AttachComponentToSocket(LightAttachment,LightAtc3P);
    }
    
    super.PostbeginPlay();
    
    }
    
    simulated function CustomFire()
    {
    if ( LightAttachment != None )
    {
    if (LightAttachment.bEnabled)
    {
    LightAttachment.SetEnabled(false);
    }
    else
    LightAttachment.SetEnabled(true);
    }
    }
    
    defaultproperties
    {
    LightColor=(R=192,G=160,B=24)
    LightScale=3
    
    }
    **i want this particle system to be permanently on, same as the light:

    and presumably, i can attach a particle system the same way, although i cant figure it out myself at present.
    so any help would be appreciated, preferably in either Tutorial or script sample form

    -d6
    Last edited by Deliverance6; 07-28-2010 at 02:32 PM.

  2. #2

    Default

    I don't know if this is the right way but I spawn a particle effect on my custom pawn through this code on my player controller:

    Code:
    CustomFX=ParticleSystem'CustomFXs.ParticleSystems.CloudFX';
    
    WorldInfo.MyEmitterPool.SpawnEmitter(CustomFX,self.Pawn.location,,self.Pawn);
    The way I'm doing it, it ataches a particle system to my pawn. To keep the particle system permanently on, you have to check if the emitter doesnt have a duration on its properties so it keeps on looping, I think.

    Take a look at the function SpawnEmitter here: http://wiki.beyondunreal.com/UE3:Emi...)#SpawnEmitter

    I hope it helps.

  3. #3
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    thanks alot for the reply =)

    I need to ask though, what is "CustomFX"? i mean, obviously when i compile i get "bad command or expression" so what would i replace it with

  4. #4
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    98

    Default

    Code:
    CustomFX=ParticleSystem'CustomFXs.ParticleSystems.CloudFX';
    CustomFX is probably his FX package where all of his effects are stored.

  5. #5
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    thats what i was thinking. but the
    Code:
    CustomFX=ParticleSystem'blah'
    is whats giving me problems cos i dont understand what "CustomFX is supposed to be

  6. #6
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    ok, got a bit further with it, but still having issues.

    on compile i get "Function is not allowed here" regardless of its location in the script.

    Code:
    //particles
    simulated function ParticleSystemComponent()
    {
    CustomFX=ParticleSystem'D6_Torch.Effects.Fire01';
    WorldInfo.MyEmitterPool.SpawnEmitter(CustomFX,self.Pawn.location,,self.Pawn);
    }

  7. #7
    MSgt. Shooter Person
    Join Date
    Jul 2006
    Posts
    163

    Default

    CustomFX is a particlesystem and needs to be declared like this:-


    Code:
    var ParticleSystem CustomFX;


    CustomFXs is the package that the particle emitter is in.

  8. #8
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    Code:
    //D6 Torch Light
    
    class UTWeap_D6_TorchLight extends UTWeap_D6_Torch;
    
    var ParticleSystem D6_Torch;
    var UDKSkeletalMeshComponent D6_Mesh;
    
    //blah other code here for the light
    
    
    //particles
    
    D6_Torch=ParticleSystem'D6_Torch.Effects.Fire01';
    D6_Mesh=SkeletalMesh'D6_Torch.Mesh.SK_WP_Torch';   //gives type mismatch error
    
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(D6_Torch, D6_Mesh, FireSocket,,,);
    im now getting a type mismatch = error on compile for "D6_Mesh=SkeletalMesh'D6_Torch.Mesh.SK_WP_Torc h';"

    any advice?

    and thanks Cpt_SLOG, i understand that now =)
    Last edited by Deliverance6; 07-28-2010 at 04:21 PM.

  9. #9

    Default

    Yeah I forgot to add that declaration code, I just wanted to give you a general idea. CustomFX is a variable which stores the particle system on CustomFXs package(My packages aren't really named like that, I just wrote this code to point you in the right direction).

    I think you have a type mismatch error because you declare 'D6_Mesh' as an 'UDKSkeletalMeshComponent' and when you are initializing it you do it as 'SkeletalMesh', though I am not sure. Try to change the declaration to whatever suits your needs.

  10. #10
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    changed it to "var SkeletalMesh D6_Mesh;"

    now im gettin a
    Error, Type mismatch in Call to 'SpawnEmitterMeshAttachment', parameter 2

    lol, not my day today is it

  11. #11

    Default

    That is because your D6_Mesh is a 'SkeletalMesh' and when you call 'SpawnEmitterMeshAttachment' you have to give it a 'SkeletalMeshComponent' parameter.
    The variable types must match in either the declaration, the initilization and the function call. So I guess that what you need to do is this:

    Code:
    var SkeletalMeshComponent D6_Mesh;
    ...
    
    D6_Mesh=SkeletalMeshComponent'D6_Torch.Mesh.SK_WP_Torch';
    ...
    
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(D6_Torch, D6_Mesh, FireSocket,,,);

  12. #12
    MSgt. Shooter Person
    Join Date
    Jul 2006
    Posts
    163

    Default

    It should be a SkeletalMeshComponent

    LOL

    Must use quick reply next time

    function ParticleSystemComponent SpawnEmitterMeshAttachment( ParticleSystem EmitterTemplate, SkeletalMeshComponent Mesh, name AttachPointName,
    optional bool bAttachToSocket, optional vector RelativeLoc, optional rotator RelativeRot )
    Last edited by Cpt_SLOG; 07-28-2010 at 04:45 PM.

  13. #13
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    ok, fixed that by correcting spelling mistakes :P

    im having the same problem with Parameter 3 however, "name AttachPointName". Unreal Wiki's types page doesnt really specify what in the hell this is supposed to be and weather i need to VAR it.

    http://wiki.beyondunreal.com/Name#Name

    http://wiki.beyondunreal.com/UE3:Emi...MeshAttachment

    what i mean is, do i mark it as a bone name? if i do, does that invalidate Parameter 4 (the socket name)

    *edit

    Marked Parameter as a bone name (Bone_02). didnt like it, same issues
    Last edited by Deliverance6; 07-28-2010 at 04:56 PM.

  14. #14

    Default

    # AttachPointName - bone or socket to attach to
    # bAttachToSocket - opt) - whether AttachPointName is a socket or bone name
    I guess that explains it, AttachPointName is the name of the socket or bone you want to attach the emitter and the 4th parameter(bAttachToSocket) is an optional bool var that tells the function if AttachPointName is a bone or a socket.

    Make sure Bone_02 exists and is passed like 'Bone_02'.
    Last edited by PrA; 07-28-2010 at 05:03 PM.

  15. #15
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    ya, but i have 2 bones in my simple torch, Bone01 and Bone02.

    and putting either of these into Parameter 3 gives me the same errors i was getting before, so do i need to declare it as a bone? and if so, how.

    also, thankyou for taking the time to reply, PrA and Capt_SLOG, you have been a great help tonight

  16. #16

    Default

    No, I don't think you need to declare it as a bone since the function takes a 'name' variable.
    Can you be more specific on what errors are you getting? If you are attaching the emitter to a bone and not a socket, try to pass the 4th argument(bAttachToSocket) as false.

  17. #17
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    on the part of the code:
    Code:
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(D6_Torch,D6_Mesh,Bone01,TorchFireSocket,,);
    i am getting the error:
    Src\Rail\Classes\UTWeap_D6_TorchLight.uc(50) : Error, Bad or missing expression for token: Bone01, in Call to 'SpawnEmitterMeshAttachment', parameter 3

    even if i leave the optional Parameter4 (TorchFireSocket) blank

    also i do want to attach it to the Socket rather than bone, but since Parameter 3 is mandatory, im not entierly sure how
    Last edited by Deliverance6; 07-28-2010 at 05:17 PM.

  18. #18
    Iron Guard
    Join Date
    Jan 2010
    Location
    Ottawa, Canada
    Posts
    777

    Default

    Doesn't help that your flying blind.

  19. #19
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    no it doesnt, ive done plenty of scripting for UDK and UT3 but ive not had any experiance with particle systems beyond muzzleflash templates

  20. #20

    Default

    Now, take a look at the function header:
    function ParticleSystemComponent SpawnEmitterMeshAttachment( ParticleSystem EmitterTemplate, SkeletalMeshComponent Mesh, name AttachPointName,
    optional bool bAttachToSocket, optional vector RelativeLoc, optional rotator RelativeRot ).

    If you already have a TorchFireSocket you don't need to use the bone, use the socket instead. If you don't have the socket on your mesh, then use the bone. Also when you are passing a name variable it must be between '' like so: 'Bone01'.
    Most important, the parameters order must be followed. The first argument is a ParticleSystem, the second a SkeletalMeshComponent, the third name variable and so on.
    I think you are confusing things a little.

    Try this, if you have a socket use this code:
    Code:
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(D6_Torch,D6_Mesh,'NameOfTheSocket',true,,);
    if you don't have a socket, use the bone:
    Code:
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(D6_Torch,D6_Mesh,'NameOfTheBone',false,,);
    @Sir. Polaris: I think Deliverance6 is just confusing small things on his frustration prolly.
    Last edited by PrA; 07-28-2010 at 05:26 PM.

  21. #21
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    names in "'blah'"

    holy **** i feel stupid =( ive been doing this for a year and i didnt notice that.

    thanks PrA. solved for now, will post screens at the end of this thread if it all works

  22. #22
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    Code:
    //D6 Torch Light
    
    class UTWeap_D6_TorchLight extends UTWeap_D6_Torch;
    				  
    
    var ParticleSystem D6_Torch;
    var SkeletalMeshComponent D6_Mesh;
    var Color LightColor;
    var float LightScale;
    var SpotLightComponent LightAttachment;
    
    simulated function PostBeginPlay()
    {
    LightAttachment = new(self)class'SpotLightComponent';
    LightAttachment.SetLightProperties(LightScale, LightColor);
    LightAttachment.CastDynamicShadows = true;
    LightAttachment.SetEnabled(true);
    LightAttachment.InnerConeAngle = 0;
    LightAttachment.OuterConeAngle = 360;
    LightAttachment.Radius = 710.0;
    LightAttachment.FalloffExponent = 5;
    if ( LightAttachment != None )
    
    {
    SkeletalMeshComponent(Mesh).AttachComponentToSocket(LightAttachment,MuzzleFlashSocket);
    //SkeletalMeshComponent(Mesh).AttachComponentToSocket(LightAttachment,LightAtc3P);
    }
    
    super.PostbeginPlay();
    
    }
    
    simulated function CustomFire()
    {
    if ( LightAttachment != None )
    {
    if (LightAttachment.bEnabled)
    {
    LightAttachment.SetEnabled(false);
    }
    else
    LightAttachment.SetEnabled(true);
    }
    
    //particles
    
    D6_Torch=ParticleSystem'D6_Torch.Effects.Fire01';
    D6_Mesh=SkeletalMeshComponent'D6_Torch.Mesh.SK_WP_Torch';
    
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(D6_Torch,D6_Mesh,'TorchFireSocket',,);
    
    
    }
    
    defaultproperties
    {
    LightColor=(R=192,G=160,B=24)
    LightScale=3
    
    //bCrosshairImage=none
    
    }
    ok, the code in its totallity up to now.

    gives no ERRORS on compile, however still doesnt spawn the particle system at the socket (or anywhere at all).

    i know ive taken up alot of your time tonight guys, and as i said, i appreciate the help and im happy to learn but im at a loss with this

  23. #23

    Default

    Is CustomFire() ever being called? Does the light component spawn?
    Also make sure, like I said in a previous post, that the Emitter Loops(not the duration, sorry) property of the particle system is set to 0, so it loops continuously. Else you might miss it if the duration is small.

  24. #24
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    CustomFire is not called atm, but the light component does spawn perfectly.
    EDIT -

    Checked and emmiter loops is set to 0 for each component of the system

    thats the torch, with the light working but without the particles

    Last edited by Deliverance6; 07-28-2010 at 06:23 PM.

  25. #25

    Default

    Well to spawn the particles you have to call CustomFire(). The light spawns because its being created in PostBeginPlay(). You should call CustomFire() there.

  26. #26
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    changed it again so that its called by "PostBeginPlay" after the lighting components, still no joy

    **Edited to kill massive block of old code
    Last edited by Deliverance6; 07-28-2010 at 06:57 PM.

  27. #27
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    ok, the script im now using is as follows

    Code:
    //D6 Torch Light
    
    class UTWeap_D6_TorchLight extends UTWeap_D6_Torch;
    				  
    //var UDKSkeletalMeshComponent SkeletonFirstPersonMesh;
    var ParticleSystem D6_Torch;
    //var SkeletalMeshComponent D6_Mesh;
    var Color LightColor;
    var float LightScale;
    var SpotLightComponent LightAttachment;
    
    simulated function PostBeginPlay()
    {
    LightAttachment = new(self)class'SpotLightComponent';
    LightAttachment.SetLightProperties(LightScale, LightColor);
    LightAttachment.CastDynamicShadows = true;
    LightAttachment.SetEnabled(true);
    LightAttachment.InnerConeAngle = 0;
    LightAttachment.OuterConeAngle = 360;
    LightAttachment.Radius = 710.0;
    LightAttachment.FalloffExponent = 5;
    //particles
    D6_Torch=ParticleSystem'D6_Torch.Effects.Fire01';
    SkeletonFirstPersonMesh=UDKSkeletalMeshComponent'FirstPersonMesh'; //D6_Torch.Mesh.SK_WP_Torch
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(D6_Torch,SkeletonFirstPersonMesh,'ParticleSocket',,);
    
    
    if ( LightAttachment != None )
    {
    SkeletalMeshComponent(Mesh).AttachComponentToSocket(LightAttachment,MuzzleFlashSocket);
    }
    
    super.PostbeginPlay();
    
    }
    
    simulated function CustomFire()
    {
    if ( LightAttachment != None )
    {
    if (LightAttachment.bEnabled)
    {
    LightAttachment.SetEnabled(false);
    }
    else
    LightAttachment.SetEnabled(true);
    }
    
    
    
    }
    
    defaultproperties
    {
    
    Begin Object Name=FirstPersonMesh
    		SkeletalMesh=SkeletalMesh'D6_Torch.Mesh.SK_WP_Torch'
    End Object
    
    SkeletonFirstPersonMesh = FirstPersonMesh;
    
    
    
    LightColor=(R=192,G=160,B=24)
    LightScale=3
    
    
    }
    thats the complete script. gives no compile warnings or errors. The light attatchment works perfectaly, but still no joy at all on the particle system.

    im starting to wonder if im even going about this the right way, but i cant see any other since "SpawnEmitter" is for actors and wont function in a weapon script.

  28. #28
    MSgt. Shooter Person
    Join Date
    May 2010
    Posts
    62

    Default

    I don't think this is a problem with you code because I have attached a particle emitter to a skel mesh through the proprieties and it makes the particles disappear

  29. #29
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    Got it working, FINALLY. took the entire night but we got there

    will post screens when ive fixed the nodes up and got it playing ingame

  30. #30
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Stafford, UK
    Posts
    351

    Default

    Final Outcome - Problem was with the emmiter system itself and "preview" being flagged as False in the editor and not the scripts.

    Helpful Links for others doing somthing Similar:

    http://udn.epicgames.com/Three/AnimTrails.html
    http://wiki.beyondunreal.com/UE3:Emi...MeshAttachment
    http://chorrol.com/files/50/obliv20B.jpg

    Final Result:
    http://www.youtube.com/watch?v=JKGgqjbcYxw


    still needs better fire emmiter or maybe some socket tweaks cos it does jump about a bit and texture/mesh tweaks. also The light toggles on double click, so i still need a "Light torch" and a "put out torch" anim.

    still, Oblivion-Style torchs in UDK... win

    thanks for the help tonight guys/girls. much appreciated

    -D6

  31. #31
    MSgt. Shooter Person
    Join Date
    May 2010
    Posts
    62

    Default

    Cool, using socket partly solved my problem... but now the only thing is I have no control over the size, no size parameter and cant scale sockets...

    EDIT: actually no doesnt solve my problem... my skel mesh is a rag doll, id have to give it an anim for the particles to show I think
    Last edited by seria; 07-28-2010 at 09:28 PM.

  32. #32
    MSgt. Shooter Person
    Join Date
    May 2010
    Posts
    188

    Default

    what was the solution to the problem? i have a hard time getting my particle to spawn too, its the in-flight particle template for my weapon (a laser beam). What did you do in the Cascade editor?

    thanks
    Add me on msn to talk

  33. #33
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    64

    Default

    hi i'm trying exact the same thing (except that i want to use it for a third person mesh) for my sword but if i'll try it with your code i get bad errors...
    i tryied everything to get rid of them but nothing works...

    i get 2 errors:
    the first says my FireSword01Mesh isn't declared (if i make a var of it, its says i can't find 'ThirdPersonMeshy'...

    the second says for
    "SkeletalMeshComponent(Mesh).AttachComponentToSock et(LightAttachment,EffectSpawn);"
    a double call of a mesh componant is unnecessary...

    i hope you can help me...

    class MyAttachment_FireSword01Light extends MyAttachment_FireSword01;

    //var UDKSkeletalMeshComponent FireSword01Mesh;

    var ParticleSystem Sword01Flame;

    var Color LightColor;
    var float LightScale;
    var SpotLightComponent LightAttachment;

    //var SkeletalMeshComponent FireSword01Mesh;


    simulated function PostBeginPlay()
    {
    LightAttachment = new(self)class'SpotLightComponent';
    LightAttachment.SetLightProperties(LightScale, LightColor);
    LightAttachment.CastDynamicShadows = true;
    LightAttachment.SetEnabled(true);
    LightAttachment.InnerConeAngle = 0;
    LightAttachment.OuterConeAngle = 360;
    LightAttachment.Radius = 710.0;
    LightAttachment.FalloffExponent = 5;

    //particles
    Sword01Flame=ParticleSystem'BloggysAdventureEffect sPack1.Flame01';
    FireSword01Mesh=UDKSkeletalMeshComponent'ThirdPers onMeshy';
    WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment (Sword01Flame,FireSword01Mesh,'EffectSpawn',true,) ;



    if ( LightAttachment != None )
    {
    SkeletalMeshComponent(Mesh).AttachComponentToSocke t(LightAttachment,EffectSpawn);
    }

    super.PostbeginPlay();

    }

    simulated function CustomFire()
    {
    if ( LightAttachment != None )
    {
    if (LightAttachment.bEnabled)
    {
    LightAttachment.SetEnabled(false);
    }
    else
    LightAttachment.SetEnabled(true);
    }

    }


    defaultproperties
    {


    Begin Object class=SkeletalMeshComponent Name=ThirdPersonMeshy
    SkeletalMesh=SkeletalMesh'BloggysAdventureItemsPac k1.Mesh.Sword01'
    End Object
    FireSword01Mesh = ThirdPersonMeshy;


    LightColor=(R=192,G=160,B=24)
    LightScale=3
    }

  34. #34
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    64

    Default

    i looked at the paths of the mesh and particle system and both are right...
    no one has an idea?


 

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.