Announcement

Collapse
No announcement yet.

[VIDEO][CODE][UPK ASSET] Attach Ribbon Particle Trails to Your SkeletalMesh / Sword

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [VIDEO][CODE][UPK ASSET] Attach Ribbon Particle Trails to Your SkeletalMesh / Sword

    In this tutorial:

    1. the art asset you see in the video, functional ribbon trail attached to feet of skeletal mesh

    2. the code to use above asset

    3. extra info on getting Ribbon Particles working as skeletal mesh socket attachments


    ~~~



    ~~~

    Ribbon UPK Asset For You, Straight From Video

    Here is the exact art asset ribbon particle I used for the feet in this video! (Nov 2012 UDK)

    file size is 13.3 KB
    http://www.mediafire.com/?reernq8iclrpvqu

    Below is the code to use it in-game!

    ~~~

    Code to Attach Above Ribbon Trail to Your Pawn's Feet


    //in your pawn class
    Code:
    var ParticleSystemComponent LeftFootTrail;
    var ParticleSystemComponent RightFootTrail;
    
    simulated function PostBeginPlay() {
    	
    	//very important line
    	super.PostBeginPlay();
    	
    	LeftFootTrail = WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(
    		ParticleSystem'RainbowSwordRibbon', //rename to your ribbon asset
    		Mesh,
    		'LeftFoot', //replace with name of your foot socket or bone name
    		true //indicates above name is a socket not a bone
    		//you could use a bone instead and then even set
    		//relative loc and rot, but that's what sockets make easy
    	);
    	
    	RightFootTrail = WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(
    		ParticleSystem'VictoryPackage5.ParticleSystem.RainbowSwordRibbon',
    		Mesh,
    		'RightFoot',
    		true //indicates above name is a socket not a bone
    	);
    }
    Note:

    Obviously the key function in the above code is SpawnEmitterMeshAttachment

    This is what keeps the ribbon trail oriented with the socket, which then causes the ribbon trail to follow the mesh correctly since

    render axis is set to Trails_SourceUp, and the source is the emitter, attached to the mesh socket.

    See below for more info

    ~~~

    Attaching to Weapons

    You can only do this with skeletal mesh weapons, and you can use the same method as above.

    Code:
    weaponTrail = WorldInfo.MyEmitterPool.SpawnEmitterMeshAttachment(
    	ParticleSystem'VictoryPackage5.ParticleSystem.RainbowSwordRibbon',
    	weapon.mesh, //or just "mesh" if done in weapon class itself
    	'YourWeaponSocketName', 
    	true //indicates above name is a socket not a bone
    );

    ~~~

    The Special Tricks To Using Ribbon Trails on Moving Skeletal Meshes

    Required Module
    use local space = true

    Ribbon Trail Data

    TangentRecalculationEveryFrame = true


    Render Axis = Trails_SourceUp

    "source" means the emitter, and so this means particles will render along the rotation of the emitter,
    and since the emitter is attached to the moving skeletal mesh socket/bone, this is what creates the
    very nice effect of ribbon moving around with the sword or pawn feet.

    Spawn Module = This Must Be Deactivated! (click the little box to make a red X meaning it is not active
    this is the extremely counter-intuitive part, you have to disable a required module

    Instead add a new module Spawn-> Per Unit

    This is information I only learned (after much struggling) with help of our dear forum friend wkladis / ImbueFX

    So many special thanks to wkladis !

    This post by wkladis (epic forums) / ImbueFX is what made my video possible, as well as the ribbon trail asset package I am sharing with you all!
    https://www.imbuefx.com/forum-wp/#/d...ribbon-woes/p1

    ~~~

    How to Adjust Trail Length

    Ribbon Trail Data
    Max Particle In Trail Count = a very high number like 1200 is what I used

    ~~~

    How to get a "Smoother" Trail

    I used

    Ribbon Trail Data
    Distance Tessellation Step size = 1
    //small = high detail / costly, try 3 or 6 or 12 if having performance issues

    Enable Tangent Diff Intepr Scale = TRUE
    //produces smoother curve by adding extra points
    //if the ribbon is changing angles abruptly

    Tangent Tessellation Scalar = 128
    //the essential tesselation factor

    ~~~

    The Art Asset as a Reference

    Again I am giving you the entire asset you see in the video for the feet, so you can just study that for the other settings

    file size is 13.3 KB
    http://www.mediafire.com/?reernq8iclrpvqu

    ~~~


    Enjoooy!

    Rama

    #2
    I have a slight tweak to this if you are interested, which saves some memory in terms of constantly using your emitter pool.

    In your pawn class:
    Code:
    var ParticleSystemComponent LeftFootTrail;
    var ParticleSystemComponent RightFootTrail;
    //Same declarations
    
    
    
    simulated function PostBeginPlay()
    {
        //Don't touch this line.
        Super.PostBeginPlay();
    
        //Attaching components on game start.
        weapMesh.AttachComponentToSocket( LeftFootTrail, 'LeftFoot' );
        weapMesh.AttachComponentToSocket( RightFootTrail, 'RightFoot' );
    
        //Either call the activation here, in below dynamically. I.E. This is optional.
        LeftFootTrail.ActivateSystem();
        RightFootTrail.ActivateSystem();
    
    }
    
    
    //DYNAMIC TRAIL START//
    function Trails(bool bTrailsActive)
    {
        //Check whether to activate or deactivate trails.
        if(bTrailsActive)
        {
            LeftFootTrail.ActivateSystem();
            RightFootTrail.ActivateSystem();
        }
        else
        {
            LeftFootTrail.DeActivateSystem();
            RightFootTrail.DeActivateSystem();
        }
    }
    
    
    simulated function Tick(float DeltaTime)
    {        
        //Don't touch as usual. :3
        super.Tick(DeltaTime);
        if(Velocity.X < 10 || Velocity.Y < 10 || Velocity.Z < 10 )
        {
            //If the player has any velocity, then start the trailing particles.
            Trails(true);
        }
        else
        {
            //Or Stop them.
            //Or leave this part out, and let them fade out with the timing on Rama's asset.
            Trails(false);
        }
    }
    
    //DYNAMIC TRAIL END//
    
    
    DefaultProperties
    {
        //Initialize the components and add them to the class' component array.
        Begin Object Class=ParticleSystemComponent Name=ParticleSystemComponent1
            Template=ParticleSystem'VictoryPackage5.ParticleSystem.RainbowSwordRibbon'
        End Object
    
        Components.Add(ParticleSystemComponent1)
        LeftFootTrail= ParticleSystemComponent1
    
        Begin Object Class=ParticleSystemComponent Name=ParticleSystemComponent2
            Template=ParticleSystem'VictoryPackage5.ParticleSystem.RainbowSwordRibbon'
        End Object
    
        Components.Add(ParticleSystemComponent2)
        RightFootTrail= ParticleSystemComponent2
    
    }
    I'll just say I haven't actually tested this exact code, and if you are moving, the particle system might get activated every tick,
    although I'm fairly sure it should be fine, but just incase, you may need like a redundancy check. :3

    Comment


      #3
      Nice to hear from you Loken!

      Bumping this for everyone: ribbon particle resource .upk for you in the first post

      Rama

      Comment


        #4
        Rama, you are awesome!


        Hey Rama,


        Thank you so much for your tutorial!

        I made some decent use of it I think xD.

        I hope you like it! :3

        Comment


          #5
          Holy moly! Hahha!

          That's some awesome lip movement you got there, and I really like the voice / accent!

          Hee hee!

          Thanks for sharing!

          Rama

          Comment


            #6
            Bump for community, enjoy the free Ribbon Particle asset!



            Rama

            Comment


              #7
              Originally posted by evernewjoy View Post
              Bump for community, enjoy the free Ribbon Particle asset!



              Rama

              Huge thanks for this Rama, I know this is UDK not UE4 but this was the missing info I needed to get this looking right.

              Click image for larger version

Name:	cycle_trail.jpg
Views:	1
Size:	31.3 KB
ID:	3250756

              Comment

              Working...
              X