Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Chris on February 19, 2009, 03:10:40 AM

Title: how to change sound walking ?
Post by: Chris on February 19, 2009, 03:10:40 AM
how to change sound walking in which surface

for ex:

(http://www.pic-upload.de/19.02.09/gqkoea.jpg)


sound 1 in carpet

sound 2 in wood
or more
Title: Re: how to change sound walking ?
Post by: Net on February 19, 2009, 08:41:18 AM
http://res.dead-code.org/doku.php/kbase:how_do_i_implement_surface-dependent_footstep_sounds
Title: Re: how to change sound walking ?
Post by: Chris on February 19, 2009, 11:47:17 PM
what is name surface in 3d file ?

and other infomation in .geometry ?

Title: Re: how to change sound walking ?
Post by: Net on February 20, 2009, 09:14:21 AM
Don't know exactly, but from head i think, there should be "walk-planes"
Title: Re: how to change sound walking ?
Post by: HelLRaiseR on February 20, 2009, 11:57:20 AM
No, you don't need to do nothing with the walk planes. You need to make a region in the SceneEdit, for example, a region called "carpet". Then you must add a custom property when the region "carpet" is selected. A dialog window will be appear. In this dialog you can create a variable and value for this variable, for example variable:surface value;carpet

In the sprite editor (if its a 2D character) or in the act3d file (if it's a 3d character) you need to indicate in that frame WME will be send the "footstep" event.

For example:

In the act3d file

ANIMATION
  {
    NAME="walk"
    LOOPING=TRUE

    EVENT
    {
      FRAME = 10
      NAME = "footstep"
    }
}

In the 10th frame of the animation walk, WME send the "footstep" event

Now, in the actor script, you need to write the code for play the sound of the footstep in the carpet:

on "footstep"  // This is the event, this code will be execute when WME play the 10th frame of the animation,
               // this frame will bi corresponded when the foot of the actor is in teh floor, of course.
{
 // get a region the actor is standing in
 var Reg = Scene.GetRegionAt(this.X, this.Y);
 if (Reg!=null)
 {
   // play a sound depenging on a surface
   // "surface" is a custom property we defined in SceneEdit
   switch(Reg.surface)
   {
     case "carpet":
       this.PlaySound("carpet_footstep.ogg");  // If the actor is wlking on the carpet then play carpet foot step sound
     break;
     default:
       this.PlaySound("normal_footstep.ogg"); // In other case, play the normal footstep sound (floor).
     break;
   }
 }
}


If you've several surfaces, you need to define several regions, one for every surface, and create the variable "surface" and his value for every surface.

In the code, you can add several pieces of code case .... break; with the check of the surface type and play the corresponfing surface sound.

Title: Re: how to change sound walking ?
Post by: Chris on February 21, 2009, 07:19:45 PM
thanks  HelLRaiseR   ::rock
Title: Re: how to change sound walking ?
Post by: HelLRaiseR on February 23, 2009, 11:49:40 AM
You're welcome.
 ::thumbup