1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

Animations

Discussion in 'Ask a Coder' started by Gnam, Oct 28, 2004.

  1. Gnam

    Gnam Member

    Joined:
    Feb 13, 2002
    Messages:
    515
    Likes Received:
    0
    Ok, I'm making a fire mode class based on the Assault Rifle grenade fire, for a linkgun-based weapon. What I want to do is use the Linkgun alt fire animation to make it look like the gun is shaking/vibrating while it charges up. What I have so far is this:
    Code:
    function PlayStartHold()
    {
        if ( PlayerController(Instigator.Controller) != None )
        {
                Instigator.AmbientSound = Sound'WeaponSounds.BLinkGunBeam4';
        }
     
         Weapon.PlayAnim(FireAnim, HoldTime);
    
    }
    function PlayFiring()
    {
        if ( PlayerController(Instigator.Controller) != None )
        {
                Instigator.AmbientSound = None;
        }
    
        Weapon.PlayAnim(FireEndAnim);
    
    }
    function PlayFireEnd()   {}
    
    auto state Idle
    {
        function StopFiring()
        {
            local rotator r;
    
            if (Instigator.Weapon != Weapon)
                return;
    
            r.Roll = Rand(65536);
            Weapon.SetBoneRotation('Bone_Flash02', r, 0, 1.f);
    
            mNextRoll = mCurrentRoll + mRollInc;
    
            if ( (Level.NetMode != NM_Client) && (Instigator.DrivenVehicle == None) )
                Weapon.PlaySound(FireSound,SLOT_Interact,TransientSoundVolume,,512.0,,false);
            ClientPlayForceFeedback(FireForce);  // jdf
    
            GotoState('Wait');
    
            Super.StopFiring();
        }
    }
    What I did here is set the AltFire as the "Fire" animation, and the main fire as the "fire end animation.

    This usess the animation, but it freezes on one frame durring the entire hold time. I can do it without the "holdtime" property on the play animation, but then it only plays the animation for one cycle, then stops. I want it to loop for the entire time you hold the fire button.

    Also, how can I call muzzle flashes durring different states? I want to play the link beam muzzle flash durring the charge up time, then the projectile flash durring the actual fire.

    Thanks for any help in advance.
     
  2. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    instead of Weapon.PlayAnim(FireAnim, HoldTime); use Weapon.LoopAnim(FireAnim);
    That way itll loop the 'charging' animation up until it is told to play another animation (such as when it fires)

    bonus points if you make it shake faster as it charges ;)
     
  3. Gnam

    Gnam Member

    Joined:
    Feb 13, 2002
    Messages:
    515
    Likes Received:
    0
    Ah, ok, now I got it. The problem was the fact that I had a 'fireEndAnim' set. It would automatically cut off the loop after 1 cycle. Once I took it off, moved the regular fire back to the "FireAnim" and just used 'AltFire' to identify the animatino to be looped, it all worked perfectly.

    Now all that's left is the muzzle flash. Any hints?

    Also, I have a question about skins...is there some value that controls how reflective/shiny they are? I made some new weapon skins, and for some weapons they look perfect, and for some reason others they are SUPER shiny.

    Anyway, thanks a lot for all your help EvilDr.Wong. You allways answer my questions, whereas on other forums often no one even responds.
     
  4. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    For an alternate muzzle flash... Im not too sure. At the very least, youll need to jimmy it into some of the pre-existing functions, a-like so!

    Code:
    var() class<xEmitter> HoldEmitterClass;
    var() xEmitter HoldEmitter;
    
    simulated function DestroyEffects()
    {
        Super.DestroyEffects();
    
        if (HoldEmitter != None)
            HoldEmitter.Destroy();
    }
    
    simulated function InitEffects()
    {
        Super.InitEffects();
    
        if ( (HoldEmitterClass != None) && ((HoldEmitter == None) || HoldEmitter.bDeleteMe) )
        {
            HoldEmitter = Weapon.Spawn(HoldEmitterClass);
        }
    }
    
    function DrawMuzzleFlash(Canvas Canvas)
    {
        Super.DrawMuzzleFlash(Canas);
    
        if (HoldEmitter != None && HoldEmitter.Base != Weapon)
        {
            HoldEmitter.SetLocation( Weapon.GetEffectStart() );
            Canvas.DrawActor( HoldEmitter, false, false, Weapon.DisplayFOV );
        }
    }
    
    I believe thats all that would be required to get the emitter up and living (and destroyed when necessary) Now at this point youve got a couple choices... you can have ModeTick trigger the HoldEmitter every so often (to make it flash and pop and crackle and what have you) or you could devise some other nefarious scheme of updating the flash on a regular basis... For the ModeTick method, itd probably end up looking something like this:
    Code:
    var float HoldUpdateRate;                     //Only trigger the 'hold' flash this often
    var float HoldUpdateCounter;                //Internal counter... WEEEE!!
    
    function ModeTick(float deltaTime)
    {
        HoldUpdateCounter+=DeltaTime;          //Tally this sucka up. Do it all the time, for fun
    
        if(!bIsFiring)
            return;            //No need to update the 'charging' flash, we're not 'charging'!
    
    /*
    This next line says (more or less) "Have we got a client or the host of a listen
    server AND have we come to or passed the time to update the flash?"
    */
        if(Instigator.IsLocallyControlled()&&HoldUpdateCounter>=HoldUpdateRate)           
        {
            if(HoldEmitter!=None)
                HoldEmitter.Trigger(Weapon, Instigator);
            HoldUpdateCounter=0;
        }
    }
    
    now... this hasnt been tested, so dont yell or go all ape**** if it doesnt work ;) Just theory at this point in time. If it works, hell yeah. If it dont, say so. Im not gonna just leave you hanging ;)


    edit: Im not much of an artist... but Im inclined to say that a dark texture will have a more apparent 'shine' to it with a specular than a midtone or light texture would. The shine isnt changing, but the contrast could make it seem like its stronger or whatever... I think?
     
    Last edited: Oct 29, 2004
  5. Gnam

    Gnam Member

    Joined:
    Feb 13, 2002
    Messages:
    515
    Likes Received:
    0
    YES!! Nice shot! Worked first try. You rock!

    Ok, there's just one more thing I need to do with this weapon, and then it'll be perfect. I was trying to change the color of the link trail effect from the firemode classes, but according to UCC you're not alowed to change it's properties from outside the effect class. So I copied the trail effect into my package folder and made the changes I wanted, but UCC pulls up an error for the fire class saying it can't find the effect. I quadruple-checked the path, and it was correct, so I can only guess that something special must be done to access effects outside of the Xeffects package. Any clues?

    Also, on another subject, I'm working on a "quad damage" powerup, which double damage scaling in addition to enabling UDamage. The only problem is reseting damage scaling back to 1 when the Udamage wears off. I saw another guy was trying to do the same thing, but he never managed to get it to turn off either. Any suggestions?

    Edit- damn, I keep on having more questions. I guess I'll just edit them in as I think of them and then you can answer as many as you feel like.

    3) Ok, on a different weapon, it fires projectiles rapid fire for primary fire, and for alt fire, it fires 6 projectiles in spread (like the flak cannon) with a longer reload time. The multifire effect is created by the AmmoPerFire setting, not the ProjPerFire setting. What I decided to do is when the ammo runs below the AmmoPerFire setting, it should just fire as much ammo as is left; ie if there's only 5 ammo left, fire 5 projectiles. What I ended up doing is adding...
    Code:
        If ( Weapon.AmmoAmount(ThisModeNum) < 6)
            AmmoPerFire = Weapon.AmmoAmount(ThisModeNum);
        Else
            AmmoPerFire = default.AmmoPerFire;
    
    It sort of works, but there are some wierd bugs. The first time you fire the alt fire, it only fires 1 projectile and doesn't consume ammo. Then it fires the normal amount, and if you alt fire down to under 6, the next alt fire will fire and consume whatever you have left, but if you primary fire down to under 6, then use Alt Fire, you get free 1 shot of 6 projectiles that doesn't use any ammo, then the next time you fire, it uses and consumes whatever you have left. I'm guessing it has something to do with the place where I put the if/then statement not being the proper place where the game regularly checks AmmoPerFire, but I don't really know. I must have done something right though, since it almost works.

    4) I'm trying to use the UT2003 assault rifle 3rd person model for a weapon, but the default animations for the model are messed up (they are upside down). Fortunately, there is an animation set called "garbage" in the same package that puts it right side up. Is there a way I tell it to use that animation set, instead of the default, in the atachment default properties (like the skins method)?

    5) Is there a way to edit the InitialAmount value for ammo types from within a mutator? I initially made the initial amounts for my weapons low to allow more ammo control in small matches with weapons stay, but for larger games, I would like the option of doubling it.

    By the way, I figured out that the problem with the skins was because of the "High Detail Overlay" in the default properties of most UT2004 weapons. I deleted it from my weapons' properties, and now they look much better.
     
    Last edited: Oct 31, 2004
  6. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    :eek:

    youre gonna have to give me a day or two for this...
     
  7. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    1) Effects arent treated any differently than any other object... ie: If youve loaded its package, itll show up. xEffects doesnt have any magic behind it making it the only effect package.
    2) Im not sure what you mean about the quad damage.
    3) You're gonna have to post more code than just the ammo stuff there, the problem isnt with that bit you posted.
    4) Youre gonna have to explain that one more... The stock 3rd person models dont have any animations...
    5) Yeah, there probably is. Using either PostBeginPlay to set the class's default values, or CheckReplacement, you should be able to do it from there.
     
  8. Gnam

    Gnam Member

    Joined:
    Feb 13, 2002
    Messages:
    515
    Likes Received:
    0
    1) I figured out what was wrong with the effects. I forget exactly what it was now, but I think I was just using the wrong variable or something.

    2) Ok, what my quad damage does is add damage scaling to the player, in adidition to the Udamage effect. It sets the player's damage scaling to 2 so added to the Udamage effect it's a 4x increase. The problem is reseting the player damage scaling to 1 when the Udamage wears off.

    3) OK, here is the entire code:

    Code:
    class NailAltFire extends ProjectileFire;
    
    function DrawMuzzleFlash(Canvas Canvas)
    {
        if (FlashEmitter != None)
        {
            FlashEmitter.SetRotation(Weapon.Rotation);
            FlashEmitter.Skins[0] = FinalBlend'XEffectMat.LinkMuzProjYellowFB';
            FlashEmitter.mSizeRange[0]=0.9;
            FlashEmitter.mSizeRange[1]=1.4;
    
            Super.DrawMuzzleFlash(Canvas);
        }
    }
    
    simulated function PostBeginPlay()
    {
        If ( Weapon.AmmoAmount(ThisModeNum) >= 6)
            AmmoPerFire = 6;
        else If ( Weapon.AmmoAmount(ThisModeNum) <= 5)
            AmmoPerFire = Weapon.AmmoAmount(ThisModeNum);
        else        
            AmmoPerFire = 6;
        Load = AmmoPerFire;
    }
    
    event ModeDoFire()
    {
        if (!AllowFire())
            return;
    
        if (MaxHoldTime > 0.0)
            HoldTime = FMin(HoldTime, MaxHoldTime);
    
        // server
        if (Weapon.Role == ROLE_Authority)
        {
            Weapon.ConsumeAmmo(ThisModeNum, Load);
            DoFireEffect();
    		HoldTime = 0;	// if bot decides to stop firing, HoldTime must be reset first
            if ( (Instigator == None) || (Instigator.Controller == None) )
    			return;
    
            if ( AIController(Instigator.Controller) != None )
                AIController(Instigator.Controller).WeaponFireAgain(BotRefireRate, true);
    
            Instigator.DeactivateSpawnProtection();
        }
    
        // client
        if (Instigator.IsLocallyControlled())
        {
            ShakeView();
            PlayFiring();
            FlashMuzzleFlash();
            StartMuzzleSmoke();
        }
        else // server
        {
            ServerPlayFiring();
        }
    
        Weapon.IncrementFlashCount(ThisModeNum);
    
        // set the next firing time. must be careful here so client and server do not get out of sync
        if (bFireOnRelease)
        {
            if (bIsFiring)
                NextFireTime += MaxHoldTime + FireRate;
            else
                NextFireTime = Level.TimeSeconds + FireRate;
        }
        else
        {
            NextFireTime += FireRate;
            NextFireTime = FMax(NextFireTime, Level.TimeSeconds);
        }
    
        If ( Weapon.AmmoAmount(ThisModeNum) >= 6)
            AmmoPerFire = 6;
        else If ( Weapon.AmmoAmount(ThisModeNum) <= 5)
            AmmoPerFire = Weapon.AmmoAmount(ThisModeNum);
        else        
            AmmoPerFire = 6;
    
        Load = AmmoPerFire;
        if (Instigator.PendingWeapon != Weapon && Instigator.PendingWeapon != None)
        {
            bIsFiring = false;
            Weapon.PutDown();
        }
    }
    
    function Projectile SpawnProjectile(Vector Start, Rotator Dir)
    {
        local NailProj Proj;
    
        Proj = Weapon.Spawn(class'GWTWeapons.NailProj',,, Start, Dir);
        return Proj;
    }
    
    simulated function bool AllowFire()
    {
         return ( Weapon.AmmoAmount(ThisModeNum) > 0);
    }
    
    defaultproperties
    {
         ProjSpawnOffset=(X=25.000000,Y=8.000000,Z=-3.000000)
         FireEndAnim=
         FireAnimRate=0.950000
         FireSound=SoundGroup'WeaponSounds.FlakCannon.FlakCannonFire'
         FireForce="FlakCannonFire"
         FireRate=1.100000
         AmmoClass=Class'gwtweapons.NailAmmo'
         ShakeRotTime=2.000000
         ShakeOffsetMag=(X=-20.000000)
         ShakeOffsetRate=(X=-1000.000000)
         ShakeOffsetTime=2.000000
         ProjectileClass=Class'gwtweapons.NailAltProj'
         BotRefireRate=1.500000
         FlashEmitterClass=Class'XEffects.LinkMuzFlashProj1st'
         Spread=560.000000
         SpreadStyle=SS_Random
    }
    4) Are you sure you're not thinking of the static meshes? I attached 2 shots of what I'm talking about.

    5) I'm not really sure how I would go about doing this. I've never seen properties changed from Postbeginplay, and I don't want to make duplicate classes of all ammo and then replace all of them with Checkreplacement. Unfortunately, it seems there aren't many mutators out there that handle this type of thing, so it's hard to learn from example. Any way you could point me in the right direction or be a bit more specific? Thanks.
     

    Attached Files:

    Last edited: Nov 7, 2004
  9. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    2) Hmm... Im not sure how powerups work (as odd as that sounds, Ive only ever used Inventory/Pickup :p) but Im assuming it wouldnt be impossible to tack some extra actor onto the pawn that watches its UDamage status, then reverts DamageScaling as soon as it sees a change

    3) Alright. Its looking like your best bet is to alter ModeDoFire to change how much ammo it tells the weapon to consume. Since ammo count is pushed to the client from the server, its not important for the client to bother figuring out how much to consume, so AllowFire can be reverted back to checking for just AmmoPerFire (which should be set at one, the least amount of ammo the weapon will fire with)
    Code:
    event ModeDoFire()
    {
        //yadda yadda yadda, everything else other than this block should be the same
        if (Weapon.Role == ROLE_Authority)
        {
            Load=Min(Weapon.AmmoAmount(ThisModeNum),6);
    
            Weapon.ConsumeAmmo(ThisModeNum, Load);
    
            DoFireEffect();
            HoldTime = 0;	// if bot decides to stop firing, HoldTime must be reset first
            if ( (Instigator == None) || (Instigator.Controller == None) )
                return;
    
            if ( AIController(Instigator.Controller) != None )
                AIController(Instigator.Controller).WeaponFireAgain(BotRefireRate, true);
    
            Instigator.DeactivateSpawnProtection();
        }
        //peepee caca doodoo
    }
    
    simulated function bool AllowFire()
    {
        return ( Weapon.AmmoAmount(ThisModeNum) >= AmmoPerFire );
    }
    
    And that way, with Load being changed before projectiles are created, itll automatically account for the extra ammo used and create more projectiles.

    4) Third person meshes are supposed to be upside down like that. Its got something to do with the skeleton of the player models and the alignment of the bones or some crap. If using the regular 3rd person mesh isnt solving anything, try setting its DrawScale3d to (X=1.0,Y=1.0,Z=-1.0) and see if that sorts the upside down weapons problem.

    5) You could change the class' properties in a mutators PostBeginPlay like so:
    Code:
    function PostBeginPlay()
    {
        class'YourAmmo'.default.InitialAmount=500;
        class'YourAmmo'.default.PickupAmmo=500;
        class'YourAmmoPickup'.default.AmmoAmount=500;
    }
    
     
  10. Gnam

    Gnam Member

    Joined:
    Feb 13, 2002
    Messages:
    515
    Likes Received:
    0
    Allright, cool, looks like I'm good to go, thanks. I don't have time to see if these work right now, but I have a quick question on the initial ammo thing- is there a way I could modify the base "Ammunition" class all ammo types automatically (ie initialamount= (default.initialammount * 2) or something like that? It's not a lot of trouble to just make a line for every individual class, but if the other option was equally un-complicated it could streamline the code a bit.

    Edit: LOL, the problem with the 3rd person turned out the "relative rotation" setting. I deleted it by accident when I was trying to mess with drawscale and relative location, and suddenly it was perfect.

    Edit2: Ok, this is a wierd glitch. Back to the nailgun, if you use the primary fire to go below 6 ammo, then alt fire won't work. If you use the secondary to go below 6 (ie you have 11 rounds left, then you use alt fire) then alt works perfectly and fires the remaining 5 rounds. The good news is with your code the rest of the glitches don't happen (like the alt fire only firing 1 proj on the first shot, or firing extra shots without using ammo).

    Edit3: OK, I changed the "allow fire" again back to >1 instead of >ammoperfire and the problem I mentioned above is gone. I dont see any other side effects, so it seems like it should stay this way even though you said to make it >ammoperfire. Right now, everything seems to work perfectly.
     
    Last edited: Nov 8, 2004
  11. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    If you wanted to make all ammo 'doubled' youd most likely have to jimmy that into the CheckReplacement function. See, almost every actor gets run through that function/set of functions to decide whether or not its necessary for gameplay or if something wants to replace it/modify it.
    So in CheckReplacement youd look at what type of actor Other is (Other being the incoming actor) and if its an ammo pickup, youd then modify those relevant values.
     
  12. Gnam

    Gnam Member

    Joined:
    Feb 13, 2002
    Messages:
    515
    Likes Received:
    0
    Hmm.... I think I'll stick with PostBeginPlay cause I know how to do it and it's easy....even though my mod has like 20 different ammo types at this point :eek: .

    Oh yeah, while I'm at it, off the top of your head is there any simple way to control the size/width proportions of random shot spread? Ie: spread:'(X)=1000,(y)=700' ? If there was, it would help on this shotgun thing I'm working on.

    Also, on Quad Damage- xPawn spawns a class called "UdamageTimer" to monitor the status of Udamage and deactivate the effects when the time runs out. Would it be possible to simply code the Qdamage pickup to monitor the UdamageTimer and reset damage scaling whent the UdamageTimer runs out and is destroyed?
     
    Last edited: Nov 9, 2004

Share This Page