Is it possible to attach an emitter to a player model without a new species?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Radiosity

Minty Fresh!
Jan 3, 2003
2,217
0
0
45
UK
www.radiant-studios.net
I'm working with Slyrr77 to implement a special effect on a new character model he's creating, and I would like to use an emitter class to achieve the desired result. However, it seems like the only way to do this is to use a custom species, which I'm not even going to think about thanks to the rubbish handling of species classes online. I've tried adding an emitter to the spine bone in a custom voicepack using PostBeginPlay, and also tried using a new function (AttachEmitEffect) and calling that from a Timer (the Timer is set in PostBeginPlay as well), but so far nothing I've tried has resulted in an emitter being attached to the spine of any model in the game. The model Slyrr is making will have a custom skeleton, so it wouldn't be a problem to add an extra bone specifically for this.

So... would this actually be possible? Am I just going about it the wrong way? Or is a custom Species the only feasible option? If it is, then we'll have to fall back to PlanB and use animated materials instead.

Thanks in advance :)
 

MythOpus

You Have Witnessed The MythMaster @ Work
Jul 22, 2003
19
0
0
34
Canada
www.freewebs.com
Radiosity said:
I'm working with Slyrr77 to implement a special effect on a new character model he's creating, and I would like to use an emitter class to achieve the desired result. However, it seems like the only way to do this is to use a custom species, which I'm not even going to think about thanks to the rubbish handling of species classes online. I've tried adding an emitter to the spine bone in a custom voicepack using PostBeginPlay, and also tried using a new function (AttachEmitEffect) and calling that from a Timer (the Timer is set in PostBeginPlay as well), but so far nothing I've tried has resulted in an emitter being attached to the spine of any model in the game. The model Slyrr is making will have a custom skeleton, so it wouldn't be a problem to add an extra bone specifically for this.

So... would this actually be possible? Am I just going about it the wrong way? Or is a custom Species the only feasible option? If it is, then we'll have to fall back to PlanB and use animated materials instead.

Thanks in advance :)

I never thought of doing something like that using a new species actually. I have however found a particularly easy way to attach emitters or the like to pawns. Try this:
Code:
var class<Emitter> EmitterVar, SpawnedEmitter;

function PostBeginPlay()
{
  TheEmitter = Spawn(SpawnedEmitter, self,, Location, Rotation);
  AttachToBone(TheEmitter, spine);
}

Put that into a custom 'pawn' class or use it in a like matter. I'm not exactly sure if that's all exactly right, due to the fact that I'm using my school computer at the moment :rolleyes: Hope that helps even a little bit. The basic thing is just Spawn an emitter and attach it to the spine. Of course, there's the whole 'only wanting this for one model'... So I'm not sure if you make this for model only code :(
 

Radiosity

Minty Fresh!
Jan 3, 2003
2,217
0
0
45
UK
www.radiant-studios.net
The problem is this is for a custom character, not a custom pawn. It's not a new gametype or anything, so creating a new pawn subclass is out of the question. chip, the point about using a species class is that it is assigned to a model from game start, so custom emitters can logically be attached to a model through the species. But a custom species breaks net compatibility completely (even having a custom species in your system folder means you simply can't join any game at all). MythOpus, that is how I'm attempting to attach the emitter now, but it doesn't want to work using a voicepack, and I can't currently think of any way to use another external class to attach something to a specific bone.

I get the feeling we're going to have to use materials, which kinda sucks, because I can't have the material destroy itself when the character dies, and that'll look dodgy. With an emitter, I can easily destroy it, and plus an emitter simply looks way better than an animated material ever could.
 

MythOpus

You Have Witnessed The MythMaster @ Work
Jul 22, 2003
19
0
0
34
Canada
www.freewebs.com
Could you not simply use an implementation of a TriggeredMaterial and some sort of... MaterialTrigger? You could trigger the material off when the player dies or something?
 

chip

New Member
Nov 14, 2002
524
0
0
Visit site
this may give you a good place to start. compile, then place one in a level to test. the Emitters(0) object will of course need to be re-defined for your use.
Code:
//=====================
// RadsEmitter.
//=====================
class RadsEmitter extends Emitter
	placeable;

var Pawn PlayerPawn;
var bool bAttached;
var PlayerController P;


event Tick(float DeltaTime)
{
  local Pawn LocalPlayerPawn;
  local int i;

  if(!bAttached);
    forEach DynamicActors(class'Pawn', LocalPlayerPawn)
      if(LocalPlayerPawn.Controller != none && LocalPlayerPawn.Controller.IsA('PlayerController'))
      {
         PlayerPawn = LocalPlayerPawn;
         P = PlayerController(LocalPlayerPawn.Controller);
//         SetOwner(PlayerPawn);
         PlayerPawn.AttachToBone(self, 'spine');
         bAttached = true;
         for( i=0; i < Emitters.Length; i++)
           Emitters[i].Disabled = false;
      }
  else
    // kill particles if pawn dead
    if( bAttached && P.Pawn == none )
    {
      for( i=0; i < Emitters.Length; i++)
        Emitters[i].Disabled = true;

      bAttached = false;
    }
}


defaultproperties
{
    Begin Object Class=SpriteEmitter Name=SpriteEmitter01
        UseDirectionAs=PTDU_Up
        Disabled=true
        RespawnDeadParticles=True
        UniformSize=True
        AutomaticInitialSpawning=True
        MaxParticles=10
        StartSizeRange=(X=(Min=10.000000,Max=10.000000))
        InitialParticlesPerSecond=10.000000
        Texture=Texture'EmitterTextures.Flares.EFlareG2'
        LifetimeRange=(Min=0.500000,Max=0.500000)
        StartVelocityRange=(X=(Min=-300.000000,Max=300.000000),Y=(Min=-300.000000,Max=300.000000),Z=(Min=-300.000000,Max=300.000000))
    End Object
    Emitters(0)=SpriteEmitter'SpriteEmitter01'
}
feel free to revise as necessary. if you don't want the RadsEmitter to stop emitting when the Pawn is dead, just rewrite that part to not disable the ParticleEmitters. i can't test this for netplay, so you will likely have to revise a bit to get things working online, but the basic method seems sound.

in my test level, i used a stock Epic character for playtesting, so using it shouldn't require any special treatment in that regard.

edit note: i commented out the SetOwner line because i realized it was not necessary... just a leftover from an earlier version.
 
Last edited:

Radiosity

Minty Fresh!
Jan 3, 2003
2,217
0
0
45
UK
www.radiant-studios.net
Sweet, thanks muchly chip :tup: I'll test this tomorrow and report back with results. Of course, because I can get Slyrr to add a custom bone for this to attach to, I don't need to worry about it attaching to every model in the game too, so that's a big bonus :) Thanks again chip
 

draconx

RuneUT
Jun 26, 2002
325
0
0
36
Waterloo, Canada
Hmmm is that the same Slyrr that did a bunch of the jHeretic & jHexen models? If so you've got a very talented modeller on your side :)
Will be interesting to see what comes up if this works.
 

pospi

New Member
Jun 30, 2003
298
0
0
www.pospi.cjb.net
attaching to a species is definitely the easiest way for a player model. You can attach emitters to things with inventory items, but in that case youre going to end up writing a mutator anyways which kind of defeats the purpose of a character model.

Do it with a custom species - it's not too difficult at all.

This is a shot of a player model I made quite a long while back (sorry for the poor coding heh) for UT2k3 that does what you are talking about:
shot2.jpg

It runs fine on ut2k4, minus vehicle anims, so you would be fine to use the same code. Just install it, then decompile the somosPs.u in your system folder using ucc like so:
Code:
ucc batchexport somosPs.u class .uc c:\whereverr
There's also some info in an *.int file that from memory may have been important, but im not entirely sure on that one.

http://student.ci.qut.edu.au/~n4405714/projects/somosModel/somos2k3.zip

Good luck! and please give credit etc
 
Last edited:

Radiosity

Minty Fresh!
Jan 3, 2003
2,217
0
0
45
UK
www.radiant-studios.net
drakonx - yup, same guy :D He's working on Professor Farnsworth from Futurama at the moment, including one of the Prof's cool floating armchairs. There are various fun animations planned, such as falling asleep in the chair and so on ;)

pospi - thanks, but I've already mentioned a couple of times that a custom species is out of the question, otherwise I'd have used that method and wouldn't have needed to post this. Any custom species class at all in your system folder will cause netplay to fail.
 

chip

New Member
Nov 14, 2002
524
0
0
Visit site
one note about Emitters: they do not Destroy() -- the function returns a false, which indicates indestructibility -- very likely because the ParticleEmitters are Objects that reference Actors, and a simple Destroy would lead to garbage collection issues. Emitters instead have a native Kill() function. unfortunately, that seems to mean that Destroyed() is not called for Emitters (i wanted to use it to respawn a Kill(ed) emitter in another version of RadsEmitter but couldn't get the function to be called). that's one reason why the posted RadsEmitter just persists between player pawn spawns, turning itself off or on as necessary.
 

Radiosity

Minty Fresh!
Jan 3, 2003
2,217
0
0
45
UK
www.radiant-studios.net
Yeah, I've had to use Emitter.Kill() a few times. It's not normally an issue with things like projectiles or muzzle flashes though, the Destroyed function works fine.



edit: Ok, either I'm missing something, or I still need a way to actually spawn this emitter class in-game. The class by itself isn't doing anything. I really think I'm going to have to use materials instead of an emitter :( Apart from a custom voicepack (which doesn't seem to work for spawning things ingame) I don't think there is a class I can use to spawn an emitter ingame except species. Or by using a mutator which, as already mentioned, defeats the objective of a character model. Any suggestions chip? Ideas for how to actually spawn this ingame already attached to a model from match start would be most welcome. Especially since Slyrr is at the UVmapping stage and kinda needs to know whether or not to keep the poly skirt he's added for a custom material or whether we'll just need a custom bone for an emitter.

Thanks again :)
 
Last edited:

chip

New Member
Nov 14, 2002
524
0
0
Visit site
Radiosity said:
Ok, either I'm missing something, or I still need a way to actually spawn this emitter class in-game. The class by itself isn't doing anything.
did you place an instance of RadsEmitter in the test level? RadsEmitter is not spawned, its already in the level at startup (but disabled), and seeks out the local player's pawn (that's the iteration), then calls that pawn's AttachToBone function, and enables the ParticleEmitters. when the Pawn dies, it shuts off (but does not Destroy or Kill itself), and waits for the player to respawn, and starts the cycle again.

worked fine in my test level -- should i send you a copy of it?

edit: i'll get back into this tonight and see if i can find a way to associate the emitter with a specific character and get it to spawn at startup so it doesn't have to be placed.
 
Last edited:

Radiosity

Minty Fresh!
Jan 3, 2003
2,217
0
0
45
UK
www.radiant-studios.net
Ah, no I didn't try placing it in a level. That would explain why it doesn't work :) But yes, it would need to be attached right from the outset without being placed in a level by hand, and my poor brain is aching quite a lot from trying to think of a way to do this without accessing a custom species (damn epic and their rubbish handling of characters - no custom pain and death sounds sucks badly enough as it is, but this takes the biscuit to a whole new level of crumminess...)

Thanks once again chip, you are indeed the daddy :D
 

chip

New Member
Nov 14, 2002
524
0
0
Visit site
yeah, i'd have liked to offer a more complete solution but wanted to get a few basics down first, then ran outta time (old geezers need their Zs). i've been scanning the classes here at work (no UEd) but haven't found any new info that might be helpful. there seem to be few handles to hang this Emitter on, other than those already mentioned but not usable for some reason.

maybe in the dark and dusty corners of the Animations browser...
 

chip

New Member
Nov 14, 2002
524
0
0
Visit site
OK, really on the right track now, i think. the key did lay in the Animations browser. under the Notify tab, you can select an option for AnimNotify_Effect, which spawns a specified class at the specified frame of the specified anim sequence. GREAT! a way to spawn something that is inherently based in the skeletal mesh!

problem is, it spawns something at every specified frame, and the emitters just keep adding up. so rather than spawning an emitter directly, i wrote an Actor that spawns a RadsEmitter, and use AnimNotify_Effect to spawn the spawner:
Code:
//-----------------------------------------------------------
// RadsEmitterSpawner
//-----------------------------------------------------------
class RadsEmitterSpawner extends Actor;

event Tick(float DeltaTime)
{
  local RadsEmitter OldRadsEmitter, NewRadsEmitter;

  forEach DynamicActors(class'RadsEmitter', OldRadsEmitter)
  {
    Destroy();
    return;
  }

  NewRadsEmitter = Spawn(class'RadsEmitter');
}

DefaultProperties
{
   bHidden=true
}
this actor also checks each tick to see if a RadsEmitter already exists, and if it does, it self-destructs and the script terminates. so only one RadsEmitter gets spawned (and it follows the Players pawn from then on), and the RadsEmitterSpawner just gets spawned and destroys itself.

not terribly efficient, and the iteration in Tick() may not be the best practice, but it does implement an attached emitter based solely on the skeletal mesh properties (yay!)

anyone should feel free to recommend improvements. this is just a proof of concept so far, and will likely benefit from others' analyses.

to implement, just compile the 2 .ucs into a package as usual, then add the AnimNotify_Effect (EffectClass = RadsEmitterSpawner) to a custom character's anim sequences in the .ukx browser. to make sure the effect is spawned, it may be necessary to add a notify for all the sequences, but if you know exactly which anim sequence will be playing at every player spawn, that one should suffice, and will likely be more efficient (i couldn't find a way to limit AnimNotify_Effect spawns, so it happens every specified frame).

also, now that RadsEmitter is being spawned, it needs to be edited slightly to work properly: in defaultproperties: set bNoDelete=false (when true, it cannot be spawned), and in the ParticleEmitter(s) object definition(s), set Disabled=false, so it(they) will work immediately when spawned.
 
Last edited:

Radiosity

Minty Fresh!
Jan 3, 2003
2,217
0
0
45
UK
www.radiant-studios.net
I was thinking about using the anim_notify system but... wow, I wouldn't have thought of using that to attach an emitter spawning actor like this. Excellent work there chip :D Very much appreciated, and I'm sure Slyrr will too when I inform him of this bit of progress :tup:
 

chip

New Member
Nov 14, 2002
524
0
0
Visit site
you've got me intrigued as to the nature of the emitter (and the specifics of the character). i've never seen Futurama, so i have no preconceptions.
 

Caravaggio

Custom User Text goes here.
Oct 2, 2002
450
0
0
US
Visit site
I hate to bump a really old thread but I was wondering if anyone had devolped an easier way of doing this by now. There isn't too much information floating around about emitters on models unfortunately. The only information I can find besides this thread is something about skeletal meshes about half way down this page at the udn..
http://udn.epicgames.com/Two/ParticleSystems

I'd aprpeciate it if someone knows of a tutorial to cover the whole thing.