The magical dragons have nice effects attached to their wings. (Vertex Meshes – e.g the default SkaarjPack/Pikachu/QuakeMonsters do not have bones and so they can only use one of these methods). Different types of effects can be attached, such as Emitters, xEmitters and even Staticmeshes!
First I will show you how to attach effects to bones. Unfortunately VertMesh monsters cannot use this 🙁 Ok, we need to spawn and attach the effects in the PostBeginPlay function and the server doesn’t really care about these so lets make sure this only happens on the client by closing them in a netmode check like this. We also need to declare a global variable for the effects. In this example I will be using xEmitters.
var xEmitter TrailEffect[2]; simulated function PostBeginPlay() { Super.PostBeginPlay(); if ( Level.NetMode != NM_DedicatedServer) { TrailEffect[0] = Spawn(class'SpeedTrail',self); TrailEffect[0].mColorRange[0].G = 0; TrailEffect[0].mColorRange[1].R = 0; AttachToBone(TrailEffect[0], 'arm_l_upper'); TrailEffect[1] = Spawn(class'SpeedTrail',self); TrailEffect[1].mColorRange[0].G = 0; TrailEffect[1].mColorRange[1].B = 0; AttachToBone(TrailEffect[1], 'arm_r_upper'); } }
Here you can see that I am spawning 2 xEmitters and assigning them to our declared variables. For fun I have changed the colours via code. Feel free to remove these lines. Then I have used that AttachToBone function. In the first parameter we insert the referenced effect and in the second parameter the name of the bone that we wish to attach it to. If you do not know how to find the bone names for your monster then read on! I will show you how to do that next. Also note the parent call of PostBeginPlay using the Super command.
Ok, so to find the bone names, first open up the UnrealEd and navigate your way to the Animation browser and open the animation file of your chosen monster. Turn on view bones by going to View>Bones.You will notice your characters appearance changes to a type of stick man! These are the bones that control your characters movement.
To turn on the bone names go back to View and this time click on BoneNames. You will notice the names of each bone appear. These will overwhelm the view and you will need to move the camera closer to make any sense.
Thats all you have to do to find the bone names. Ok, back in your monsters .uc file we are almost finished. We just need to make sure these effects are destroyed when the monster dies. A good place to do this is the PlayDying function. Just add the following code.
simulated function PlayDying(class<DamageType> DamageType, vector HitLoc) { Super.PlayDying(DamageType, HitLoc); if(TrailEffect[0] != None) { TrailEffect[0].Destroy(); } if(TrailEffect[1] != None) { TrailEffect[1].Destroy(); } }
As you can see we first check to make sure the effects exist otherwise we will get access none errors in the log. Then if they pass that check we destroy them. Also note the Super call of PlayDying. This is to make sure all the code in this function in the parents class gets called first.
Thats it for attaching to bones. Next is a method I use when I want to attach general effects. This method can also be used for VertMesh monsters.
The next method uses the SetBase() function to attach an effect to the center of the monster. Again I will use an xEmitter in this example. The code needed is very similar to that of the first method. We spawn, attach and make sure they are destroyed. Like so.
var xEmitter TrailEffect; simulated function PostBeginPlay() { Super.PostBeginPlay(); if ( Level.NetMode != NM_DedicatedServer) { TrailEffect = Spawn(class'SpeedTrail',self); TrailEffect.SetBase(self); } } simulated function PlayDying(class<DamageType> DamageType, vector HitLoc) { Super.PlayDying(DamageType, HitLoc); if(TrailEffect != None) { TrailEffect.Destroy(); } }
We spawn the effect again in PostBeginPlay, and because we are setting the base of the effect to the monster we need to call SetBase() from the class of the effect. The first parameter in SetBase() is the actor that you wish to attach it to. In this case our monster so we just put “self” without the quotation marks. Notice the parent calls for both of those functions.
If you wanted to combine this spawning your code should look something like this.
var xEmitter TrailEffect[3]; simulated function PostBeginPlay() { Super.PostBeginPlay(); if ( Level.NetMode != NM_DedicatedServer) { TrailEffect[0] = Spawn(class'SpeedTrail',self); TrailEffect[0].mColorRange[0].G = 0; TrailEffect[0].mColorRange[1].R = 0; AttachToBone(TrailEffect[0], 'arm_l_upper'); TrailEffect[1] = Spawn(class'SpeedTrail',self); TrailEffect[1].mColorRange[0].G = 0; TrailEffect[1].mColorRange[1].B = 0; AttachToBone(TrailEffect[1], 'arm_r_upper'); TrailEffect[2] = Spawn(class'SpeedTrail',self); TrailEffect[2].SetBase(self); } } simulated function PlayDying(class<DamageType> DamageType, vector HitLoc) { Super.PlayDying(DamageType, HitLoc); if(TrailEffect[0] != None) { TrailEffect[0].Destroy(); } if(TrailEffect[1] != None) { TrailEffect[1].Destroy(); } if(TrailEffect[2] != None) { TrailEffect[2].Destroy(); } }
TIP – A monster is for fragging, not just for xmas!
Recent Comments