Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Default footstep with surface-dependent footstep sounds?  (Read 2658 times)

0 Members and 1 Guest are viewing this topic.

redfox

  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 122
    • View Profile
Default footstep with surface-dependent footstep sounds?
« on: February 19, 2007, 04:53:03 PM »

Hello.

I have been using the surface-dependent footstep sounds from the Wiki, but I would like to have a default sound play, on
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Default footstep with surface-dependent footstep sounds?
« Reply #1 on: February 19, 2007, 06:09:55 PM »

Something like this should do the trick:

Code: [Select]
on "footstep"
{
  // get a region the actor is standing in
  var Reg = Scene.GetRegionAt(this.X, this.Y);
  if (Reg!=null && Reg.xSurface != null)
  {
    // play a sound depenging on a surface
    // "xSurface" is a custom property we defined in SceneEdit
    switch(Reg.xSurface)
    {
      case "grass":
        this.PlaySound("footsteps\grass.ogg");
      break;
 
      case "wood":
        this.PlaySound("footsteps\wood.ogg");
      break;
 
      // add more sounds here...
    }
  }
  else this.PlaySound("footsteps\some_standard_sound.ogg");
}
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

redfox

  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 122
    • View Profile
Re: Default footstep with surface-dependent footstep sounds?
« Reply #2 on: February 19, 2007, 06:51:56 PM »

Thanks Mnemonic, the code works perfectly. This is exactly what I was hoping for.    :D
Logged
 

Page created in 0.036 seconds with 23 queries.