Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Footsteps when not extending UT?

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

  • Footsteps when not extending UT?

    So, I am mostly extending UDK classes, so there's no familyinfo and all that.

    What I am curious about is, what is the most common way to play footstep sounds?

    I noticed the addition of Notifies in animsets recently, which seems able to do this, I suppose I can get a notify in UC somehow?

    I was unable to find any relevant documentation on Notifies.

  • #2
    EDIT: Check this thread - http://forums.epicgames.com/showpost...4&postcount=16

    Is your Pawn class extended off of UTPawn by any chance or one of the pawn classes that doesn't have sounds/weapons by default? If that's the case I have a backup of one of my pawns extending off of the SimplePawn (The one UDK starts by default with now that has no sounds) but I edited it to allow footstep sounds. I'll gladly share!

    Comment


    • #3
      Share away!

      Comment


      • #4
        Well, as I said, I'm extending UDK not UT. So yeah, No sound stuff.

        Comment


        • #5
          I recommend you extend off of SimplePawn, not UDKPawn just because there's a lot of premade code for footstep sounds that you would have to copy by hand otherwise, but it still doesn't have all the unnecessary code that UTPawn has, and you can still leave your game info class extending off of UDKGame.


          Here's the code for my Pawn extending off of SimplePawn:

          Code:
          class CarnivalPawn extends SimplePawn;
          
          
          /****Declare SoundGroup Variable******/
          
          var class<CarnivalPawnSoundGroup> SoundGroupClass;
          
          
          /** Max distance from listener to play footstep sounds */
          var float MaxFootstepDistSq;
          
          /** Max distance from listener to play jump/land sounds */
          var float MaxJumpSoundDistSq;
          
          
          
          
          
          
          
          
          /**
           * Updates the player's eye height using BaseEyeHeight and (head) Bob settings; called every tick 
           */
          event TickSpecial( float DeltaTime )
          {
          	// NOTE: The following was pulled from UT's head bobbing features
          
          	local bool bAllowBob;
          	local float smooth, OldBobTime, Speed2D;
          	local vector X, Y, Z;
          	local int m,n;
          
          	// Set ground speed
          	GroundSpeed = CastlePawnSpeed;
          	AccelRate = CastlePawnAccel;
          
          	bAllowBob = true;
          	if ( abs(Location.Z - OldZ) > 15 )
          	{
          		// if position difference too great, don't do head bob
          		bAllowBob = false;
          		BobTime = 0;
          		WalkBob = Vect(0,0,0);
          	}
          
          	if ( bAllowBob )
          	{
          		// normal walking around
          		// smooth eye position changes while going up/down stairs
          		smooth = FMin(0.9, 10.0 * DeltaTime/CustomTimeDilation);
          		if( Physics == PHYS_Walking || Controller.IsInState('PlayerClickToMove') )
          		{
          			EyeHeight = FMax((EyeHeight - Location.Z + OldZ) * (1 - smooth) + BaseEyeHeight * smooth,
          								-0.5 * CylinderComponent.CollisionHeight);
          		}
          		else
          		{
          			EyeHeight = EyeHeight * ( 1 - smooth) + BaseEyeHeight * smooth;
          		}
          
          		// Add walk bob to movement
                             OldBobTime = BobTime;
          		   Bob = FClamp(Bob, -0.15, 0.15);
          
          		if (Physics == PHYS_Walking )
          		{
          			GetAxes(Rotation,X,Y,Z);
          			Speed2D = VSize(Velocity);
          			if ( Speed2D < 10 )
          			{
          			  BobTime += 0.2 * DeltaTime;
          			}
          			else
          			{
          				BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/GroundSpeed);
          			}
          			WalkBob = Y * Bob * Speed2D * sin(8 * BobTime);
          			AppliedBob = AppliedBob * (1 - FMin(1, 16 * deltatime));
          			WalkBob.Z = AppliedBob;
          			if ( Speed2D > 10 )
          			{
          				WalkBob.Z = WalkBob.Z + 0.75 * Bob * Speed2D * sin(16 * BobTime);
          			}
          		}
          		else if ( Physics == PHYS_Swimming )
          		{
          			GetAxes(Rotation,X,Y,Z);
          			BobTime += DeltaTime;
          			Speed2D = Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y);
          			WalkBob = Y * Bob *  0.5 * Speed2D * sin(4.0 * BobTime);
          			WalkBob.Z = Bob * 1.5 * Speed2D * sin(8.0 * BobTime);
          		}
          		else
          		{
          			BobTime = 0;
          			WalkBob = WalkBob * (1 - FMin(1, 8 * deltatime));
          		}
          
          		WalkBob *= 0.1;
          
                          if ( (Physics == PHYS_Walking) && (VSizeSq(Velocity) > 100) && IsFirstPerson() )
          		{
          			m = int(0.5 * Pi + 9.0 * OldBobTime/Pi);
          			n = int(0.5 * Pi + 9.0 * BobTime/Pi);
          
          			if ( (m != n) && !bIsWalking && !bIsCrouched )
          			{
          			  ActuallyPlayFootStepSound(0);
          			}
          		}
          
          	}
          
          	OldZ = Location.Z;
          }
          
          
          /**
           * GetPawnViewLocation()
           *
           * Called by PlayerController to determine camera position in first person view.  Returns
           * the location at which to place the camera
           */
          
          
          
          simulated function Vector GetPawnViewLocation()
          {
          	return Location + EyeHeight * vect(0,0,1) + WalkBob;
          }
          
          
          
          simulated event PlayFootStepSound(int FootDown)
          {
          	local PlayerController PC;
          
          	if ( !IsFirstPerson() )
          	{
          		ForEach LocalPlayerControllers(class'PlayerController', PC)
          		{
          			if ( (PC.ViewTarget != None) && (VSizeSq(PC.ViewTarget.Location - Location) < MaxFootstepDistSq) )
          			{
          				ActuallyPlayFootstepSound(FootDown);
          				return;
          			}
          		}
          	}
          }
          
          
          
          /**
           * Handles actual playing of sound.  Separated from PlayFootstepSound so we can
           * ignore footstep sound notifies in first person.
           */
          
          
          simulated function bool IsFirstPerson()
          {
          	local PlayerController PC;
          
          	ForEach LocalPlayerControllers(class'PlayerController', PC)
          	{
          		if ( (PC.ViewTarget == self) && PC.UsingFirstPersonCamera() )
          			return true;
          	}
          	return false;
          }
          
          
          simulated function ActuallyPlayFootstepSound(int FootDown)
          {
          	local SoundCue FootSound;
          
          	FootSound = SoundGroupClass.static.GetFootstepSound(FootDown, GetMaterialBelowFeet());
          	if (FootSound != None)
          	{
          		PlaySound(FootSound, false, true,,, true);
          	}
          }
          
          simulated function name GetMaterialBelowFeet()
          {
          	local vector HitLocation, HitNormal;
          	local TraceHitInfo HitInfo;
          	local UTPhysicalMaterialProperty PhysicalProperty;
          	local actor HitActor;
          	local float TraceDist;
          
          	TraceDist = 1.5 * GetCollisionHeight();
          
          	HitActor = Trace(HitLocation, HitNormal, Location - TraceDist*vect(0,0,1), Location, false,, HitInfo, TRACEFLAG_PhysicsVolumes);
          	if ( WaterVolume(HitActor) != None )
          	{
          		return (Location.Z - HitLocation.Z < 0.33*TraceDist) ? 'Water' : 'ShallowWater';
          	}
          	if (HitInfo.PhysMaterial != None)
          	{
          		PhysicalProperty = UTPhysicalMaterialProperty(HitInfo.PhysMaterial.GetPhysicalMaterialProperty(class'UTPhysicalMaterialProperty'));
          		if (PhysicalProperty != None)
          		{
          			return PhysicalProperty.MaterialType;
          		}
          	}
          	return '';
          
          }
          
          
          
          function PlayLandingSound()
          {
          	local PlayerController PC;
          
          	ForEach LocalPlayerControllers(class'PlayerController', PC)
          	{
          		if ( (PC.ViewTarget != None) && (VSizeSq(PC.ViewTarget.Location - Location) < MaxJumpSoundDistSq) )
          		{
          			PlaySound(SoundGroupClass.static.GetLandSound(GetMaterialBelowFeet()));
          			return;
          		}
          	}
          }
          
          function PlayJumpingSound()
          {
          	local PlayerController PC;
          
          	ForEach LocalPlayerControllers(class'PlayerController', PC)
          	{
          		if ( (PC.ViewTarget != None) && (VSizeSq(PC.ViewTarget.Location - Location) < MaxJumpSoundDistSq) )
          		{
          			PlaySound(SoundGroupClass.static.GetJumpSound(GetMaterialBelowFeet()));
          			return;
          		}
          	}
          }
          
          
          
          
          function bool DoJump( bool bUpdating )
          {
          	// This extra jump allows a jumping or dodging pawn to jump again mid-air
          	// (via thrusters). The pawn must be within +/- DoubleJumpThreshold velocity units of the
          	// apex of the jump to do this special move.
          
          
          	if (bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
          	{
          		
          		if ( bIsWalking )
          			Velocity.Z = Default.JumpZ;
          		else
          			Velocity.Z = JumpZ;
          		if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f)
          		{
          			if ( (WorldInfo.WorldGravityZ != WorldInfo.DefaultGravityZ) && (GetGravityZ() == WorldInfo.WorldGravityZ) )
          			{
          				Velocity.Z += Base.Velocity.Z * sqrt(GetGravityZ()/WorldInfo.DefaultGravityZ);
          			}
          			else
          			{
          				Velocity.Z += Base.Velocity.Z;
          			}
          		}
          		SetPhysics(PHYS_Falling);
          		
          		
          		if ( !bUpdating )
          		    PlayJumpingSound();
          		return true;
          	}
          	return false;
          }
          
          
          
          
          
          event Landed(vector HitNormal, actor FloorActor)
          {
          
          	Super.Landed(HitNormal, FloorActor);
          
          
          	if ( Velocity.Z < -200 )
          	{
          		OldZ = Location.Z;
          	}
          
          
          	if(!bHidden)
          	{
          		PlayLandingSound();
          	}
          	
          	else if (Velocity.Z < MaxFallSpeed * -0.5)
          	{
          		SoundGroupClass.Static.PlayLandSound(self);
          	}
          
          	SetBaseEyeheight();
          }
          
          
          
          
          
          defaultproperties
          {
          	SoundGroupClass=class'CarnivalPawnSoundGroup'
          	MaxFootstepDistSq=9000000.0
          	MaxJumpSoundDistSq=16000000.0
          }


          Obviously, you would search through it and change any references to CarnivalPawn or CarnivalPawnSoundGroup to your own classes. Make your sound group class extend off of UTPawn to allow the different sounds and change which ever you want. My pawn code basically borrows from the code in UTPawn to allow the pawn to check the physical material it's walking on and to play the appropriate sounds. It also contains the appropriate code to change to change footstep intervals by tweaking a few numbers. Basically a feaatureless Pawn with sounds.

          Comment


          • #6
            Any luck getting this to work?

            Comment


            • #7
              GetMaterialBelowFeet() fails for me, my pawn is a special case where I do not wish for unique sounds for unique materials anyway, but I am unsure of how to remove it without breaking it.

              Edit: I am skipping the use of soundgroup entirely, and playing the footstep sound directly in the function.

              Comment


              • #8
                I got it working, but it seems like this setup just plays the sound at an interval (the interval of the headbobbing, though my game is 3rd person), which is useless to me, as I could just as well just play the sound whenever the pawn moves with a delay.

                I'd prefer using the Notify system greatly. Really, all I need to know is how to get the notifications you can set in the animset.

                Comment


                • #9
                  Got it working, it seems like the footstep animnotify calls PlayFootStepSound(); already, so all I had to do was setup the playsound functions, and the footstep notify in the Animset.

                  Comment

                  Working...
                  X