Home Unreal Engine

Vehicle Animations (need help)

polycounter lvl 11
Offline / Send Message
BenHenry polycounter lvl 11
Hey guys,
I am trying to have my vehicle play an animation when it fires my projectile.
What do I need to do for an animation to be triggered when firing my gun on the vehicle?
But what script do I edit to tell what animation to play when firing?
Here is my UTVehicle_Cannon.uc file:
/**
 * Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
 */
class UTVehicle_Cannon extends UTVehicle
    abstract;

/** animation for the fire animation */
var UTAnimBlendByWeapon CannonBlend;

/** damage type for blade kills */
var class<DamageType> BladeDamageType;



/**
 * Plays a Vehicle Animation
 */
simulated function PlayVehicleAnimation(name EventTag)
{
    local int i;
    local UTAnimNodeSequence Player;

    if ( Mesh != none && mesh.Animations != none && VehicleAnims.Length > 0 )
    {
        for (i=0;i<VehicleAnims.Length;i++)
        {
            if (VehicleAnims[i].AnimTag == EventTag)
            {
                Player = UTAnimNodeSequence(Mesh.Animations.FindAnimNode(VehicleAnims[i].AnimPlayerName));
                if ( Player != none )
                {
                    Player.PlayAnimationSet( VehicleAnims[i].AnimSeqs,
                                                VehicleAnims[i].AnimRate,
                                                VehicleAnims[i].bAnimLoopLastSeq );
                }
            }
        }
    }
}


/**
 * Are we allowing this Pawn to be based on us?
 */
simulated function bool CanBeBaseForPawn(Pawn APawn)
{
    return bCanBeBaseForPawns && !bDriving;
}

/** DriverEnter()
Make Pawn P the new driver of this vehicle
*/
function bool DriverEnter(Pawn P)
{
    local Pawn BasedPawn;

    if ( super.DriverEnter(P) )
    {
        ForEach BasedActors(class'Pawn', BasedPawn)
        {
            if(BasedPawn != Driver)
            {
                BasedPawn.JumpOffPawn();
            }
        }
        return true;
    }
    return false;
}




simulated event EnableFullSteering()
{
    local SVehicleSimCar SimCar;

    SimCar = SVehicleSimCar(SimObj);
    SimCar.MaxSteerAngleCurve.Points[0].OutVal = SVehicleSimCar(Default.SimObj).MaxSteerAngleCurve.Points[0].OutVal;
    SimCar.MaxSteerAngleCurve.Points[1].OutVal = SVehicleSimCar(Default.SimObj).MaxSteerAngleCurve.Points[1].OutVal;
    SimCar.MaxSteerAngleCurve.Points[2].OutVal = SVehicleSimCar(Default.SimObj).MaxSteerAngleCurve.Points[2].OutVal;
}



//========================================
// AI Interface



function bool TooCloseToAttack(Actor Other)
{
    if (Pawn(Other) != None && Vehicle(Other) == None)
    {
        return false;
    }
    return Super.TooCloseToAttack(Other);
}

function IncomingMissile(Projectile P)
{
    local UTBot B;

    B = UTBot(Controller);
    if (Health < 200 && B != None && B.Skill > 4.0 + 4.0 * FRand() && VSize(P.Location - Location) < VSize(P.Velocity))
    {
        DriverLeave(false);
    }
}




simulated event RigidBodyCollision( PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent,
                    const out CollisionImpactData RigidCollisionData, int ContactIndex )
{
    // only process rigid body collision if not hitting ground, or hitting at an angle
    if ( (Abs(RigidCollisionData.ContactInfos[0].ContactNormal.Z) < WalkableFloorZ)
        || (Abs(RigidCollisionData.ContactInfos[0].ContactNormal dot vector(Rotation)) > 0.8)
        || (VSizeSq(Mesh.GetRootBodyInstance().PreviousVelocity) * GetCollisionDamageModifier(RigidCollisionData.ContactInfos) > 5) )
    {
        super.RigidBodyCollision(HitComponent, OtherComponent, RigidCollisionData, ContactIndex);
    }
}



simulated function CauseMuzzleFlashLight(int SeatIndex)
{
    Super.CauseMuzzleFlashLight(SeatIndex);

    //@FIXME: should have general code for this in UTVehicle
    if (SeatIndex == 0)
    {
        VehicleEvent('MuzzleFlash');
    }
}

/**
 * We override here as the scorpion uttlery destroys itself when it blows up!  So we need to turn off the damage effects as they
 * are out of place just floating in the air.
 **/
simulated function SetBurnOut()
{
    Super.SetBurnOut();

    if( DeathExplosion != none )
    {
        DeathExplosion.ParticleSystemComponent.DeactivateSystem();
    }

    VehicleEvent( 'NoDamageSmoke' );
}

function bool RecommendCharge(UTBot B, Pawn Enemy)
{
    local UTVehicle V;
    
    if ( Enemy.bCanFly )
    {
        return false;
    }
    V = UTVehicle(Enemy);
    return (V == None) || V.ImportantVehicle() || (V.Health > 300);
}    

/** Recommend high priority charge at enemy */
function bool CriticalChargeAttack(UTBot B)
{
    return (UTVehicle(B.Enemy) != None) && RecommendCharge(B, B.Enemy);
}
    

defaultproperties
{
    Health=300
    StolenAnnouncementIndex=5
    
    
    
    COMOffset=(x=-40.0,y=0.0,z=-36.0)
    UprightLiftStrength=280.0
    UprightTime=1.25
    UprightTorqueStrength=500.0
    bCanFlip=false
    bSeparateTurretFocus=true
    bHasHandbrake=true
    bStickDeflectionThrottle=true
    GroundSpeed=950
    AirSpeed=1100
    ObjectiveGetOutDist=1500.0
    MaxDesireability=0.4
    HeavySuspensionShiftPercent=0.75f;
    bLookSteerOnNormalControls=true
    bLookSteerOnSimpleControls=true
    LookSteerSensitivity=2.2
    LookSteerDamping=0.07
    ConsoleSteerScale=1.1
    DeflectionReverseThresh=-0.3

    Begin Object Class=UDKVehicleSimCar Name=SimObject


        MaxSteerAngleCurve=(Points=((InVal=0,OutVal=45),(InVal=600.0,OutVal=15.0),(InVal=1100.0,OutVal=10.0),(InVal=1300.0,OutVal=6.0),(InVal=1600.0,OutVal=1.0)))
        SteerSpeed=110

        LSDFactor=0.0
        TorqueVSpeedCurve=(Points=((InVal=-600.0,OutVal=0.0),(InVal=-300.0,OutVal=80.0),(InVal=0.0,OutVal=130.0),(InVal=950.0,OutVal=130.0),(InVal=1050.0,OutVal=10.0),(InVal=1150.0,OutVal=0.0)))
        EngineRPMCurve=(Points=((InVal=-500.0,OutVal=2500.0),(InVal=0.0,OutVal=500.0),(InVal=549.0,OutVal=3500.0),(InVal=550.0,OutVal=1000.0),(InVal=849.0,OutVal=4500.0),(InVal=850.0,OutVal=1500.0),(InVal=1100.0,OutVal=5000.0)))
        EngineBrakeFactor=0.025
        ThrottleSpeed=0.2
        WheelInertia=0.2
        bAutoHandbrake=true
        bClampedFrictionModel=true
        FrontalCollisionGripFactor=0.18
        ConsoleHardTurnGripFactor=1.0
        HardTurnMotorTorque=0.7

        SpeedBasedTurnDamping=20.0
        AirControlTurnTorque=40.0
        InAirUprightMaxTorque=15.0
        InAirUprightTorqueFactor=-30.0

        // Longitudinal tire model based on 10% slip ratio peak
        WheelLongExtremumSlip=0.1
        WheelLongExtremumValue=1.0
        WheelLongAsymptoteSlip=2.0
        WheelLongAsymptoteValue=0.6

        // Lateral tire model based on slip angle (radians)
           WheelLatExtremumSlip=0.35     // 20 degrees
        WheelLatExtremumValue=0.9
        WheelLatAsymptoteSlip=1.4     // 80 degrees
        WheelLatAsymptoteValue=0.9

        bAutoDrive=false
        AutoDriveSteer=0.3
    End Object
    SimObj=SimObject
    Components.Add(SimObject)

    TeamBeaconOffset=(z=60.0)
    SpawnRadius=125.0

    BaseEyeheight=120
    Eyeheight=120
    DefaultFOV=90
    CameraLag=0.07

    bReducedFallingCollisionDamage=true

    
    MomentumMult=0.5

    NonPreferredVehiclePathMultiplier=1.5

    HornIndex=0
}

Replies

  • BenHenry
    Options
    Offline / Send Message
    BenHenry polycounter lvl 11
  • BenHenry
    Options
    Offline / Send Message
    BenHenry polycounter lvl 11
    How do I customize this to work when I hit the fire button?

    /**
    * Plays a Vehicle Animation
    */
    simulated function PlayVehicleAnimation(name EventTag)
    {
    local int i;
    local UDKAnimNodeSeqWeap Player;

    if ( Mesh != none && mesh.Animations != none && VehicleAnims.Length > 0 )
    {
    for (i=0;i<VehicleAnims.Length;i++)
    {
    if (VehicleAnims.AnimTag == EventTag)
    {
    Player = UDKAnimNodeSeqWeap(Mesh.Animations.FindAnimNode('W eaponFireCannon'));
    if ( Player != none )
    {
    Player.PlayAnimationSet( VehicleAnims.AnimSeqs,
    VehicleAnims.AnimRate,
    VehicleAnims.bAnimLoopLastSeq );
    }
    }
    }
    }
    }
Sign In or Register to comment.