Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: dreamfighter on May 10, 2008, 02:41:05 PM

Title: i don't understand footstep for 2d actor
Post by: dreamfighter on May 10, 2008, 02:41:05 PM
hello everybody

since yesterday i read all the post about footsteps and really i don't understand. i saw the 3d demo trinity but i use a 2d sprite actor for my game and not a 3d actor.
so i understood that i need to copy this script

on "footstep"
{
 // 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
   // "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...
   }
 }


in myactor.script




but i don't understand about this part:

 ANIMATION
  {
    NAME="walk"
    LOOPING=TRUE
   
                EVENT
                {
              FRAME = 2
                 NAME = "footstep"
                }
      EVENT
      {
         FRAME = 20
         NAME = "footstep"
      }   

  }
i don't know where i need to put this part in my actor definition file.




my original actor definition file is:

; $EDITOR_PROJECT_ROOT_DIR$ ..\..\..\

ACTOR
{
  NAME = "Nolan"
  CAPTION=""
  SCALABLE = TRUE
  INTERACTIVE = FALSE
  X = 400
  Y = 460
  SCRIPT="actors\Nolan\Nolan.script"

  FONT = "fonts\outline_red.font"


  ANIMATION
  {
    NAME       = "idle"
   
    LEFT       = "actors\Nolan\ll\stand.sprite"
    RIGHT      = "actors\Nolan\rr\stand.sprite"
    UP         = "actors\Nolan\uu\stand.sprite"
    DOWN       = "actors\Nolan\dd\stand.sprite"

    UP_LEFT    = "actors\Nolan\ul\stand.sprite"
    UP_RIGHT   = "actors\Nolan\ur\stand.sprite"
    DOWN_LEFT  = "actors\Nolan\dl\stand.sprite"
    DOWN_RIGHT = "actors\Nolan\dr\stand.sprite"
  } 

  ANIMATION
  {
    NAME       = "walk"
   LEFT       = "actors\Nolan\ll\walk.sprite"
    RIGHT      = "actors\Nolan\rr\walk.sprite"
    UP         = "actors\Nolan\uu\walk.sprite"
    DOWN       = "actors\Nolan\dd\walk.sprite"

    UP_LEFT    = "actors\Nolan\ul\walk.sprite"
    UP_RIGHT   = "actors\Nolan\ur\walk.sprite"
    DOWN_LEFT  = "actors\Nolan\dl\walk.sprite"
    DOWN_RIGHT = "actors\Nolan\dr\walk.sprite"
     }


  ANIMATION
  {
    NAME       = "talk"
   
    LEFT       = "actors\Nolan\ll\talk.sprite"
    RIGHT      = "actors\Nolan\rr\talk.sprite"
    UP         = "actors\Nolan\uu\talk.sprite"
    DOWN       = "actors\Nolan\dd\talk.sprite"

    UP_LEFT    = "actors\Nolan\ul\talk.sprite"
    UP_RIGHT   = "actors\Nolan\ur\talk.sprite"
    DOWN_LEFT  = "actors\Nolan\dl\talk.sprite"
    DOWN_RIGHT = "actors\Nolan\dr\talk.sprite"
  }

  ANIMATION
  {
    NAME       = "turnleft"
   
    LEFT       = "actors\Nolan\ll\turn.sprite"
    RIGHT      = "actors\Nolan\rr\turn.sprite"
    UP         = "actors\Nolan\uu\turn.sprite"
    DOWN       = "actors\Nolan\dd\turn.sprite"

    UP_LEFT    = "actors\Nolan\ul\turn.sprite"
    UP_RIGHT   = "actors\Nolan\ur\turn.sprite"
    DOWN_LEFT  = "actors\Nolan\dl\turn.sprite"
    DOWN_RIGHT = "actors\Nolan\dr\turn.sprite"
  }
 
  ANIMATION
  {
    NAME       = "turnright"
   
    LEFT       = "actors\Nolan\ll\turn.sprite"
    RIGHT      = "actors\Nolan\rr\turn.sprite"
    UP         = "actors\Nolan\uu\turn.sprite"
    DOWN       = "actors\Nolan\dd\turn.sprite"

    UP_LEFT    = "actors\Nolan\ul\turn.sprite"
    UP_RIGHT   = "actors\Nolan\ur\turn.sprite"
    DOWN_LEFT  = "actors\Nolan\dl\turn.sprite"
    DOWN_RIGHT = "actors\Nolan\dr\turn.sprite"
  } 
}


so can you help me or send me an example with 2d actor sprite

thank you very much for helps

Title: Re: i don't understand footstep for 2d actor
Post by: Net on May 10, 2008, 03:11:50 PM
Yes, you have to copy this

Code: [Select]
on "footstep"
{
 // 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
   // "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...
   }
 }

to your actor.script.

Then you must define "footstep" event in SpriteEditor to your actor walk sprite

(http://img102.imageshack.us/img102/3755/footstepzg3.th.jpg) (http://img102.imageshack.us/my.php?image=footstepzg3.jpg)

and also you must have defined some areas in you scene with "xSurface" property

(http://img162.imageshack.us/img162/3126/propertyek5.th.jpg) (http://img162.imageshack.us/my.php?image=propertyek5.jpg)
Title: Re: i don't understand footstep for 2d actor
Post by: dreamfighter on May 10, 2008, 07:01:43 PM
really thank you very much net, for the explain  it's very nice of your part to post screen. i's more easy for me i'm newbies.

i followed step by step your explain, but i think i forget something, i haven't steps sound in my scene.
i verify and the steps sounds are in my sounds folder.

how can i do

Thanks
Title: Re: i don't understand footstep for 2d actor
Post by: Mnemonic on May 11, 2008, 08:33:07 AM
It's hard for *us* to tell what you forgot about :) This thread contains all the info you need, try to double-check all the steps.
Also, it's summarized in this wiki article (http://wiki.dead-code.org/wakka.php?wakka=FootstepSounds).
Title: Re: i don't understand footstep for 2d actor
Post by: Net on May 11, 2008, 10:05:14 AM
Is WME showing some error?

Try to Check syntax of your actor.script.

If you have exactly footstep method you've post, there is a mistake.
The method is not ended correctly. At the end is missing }.
Title: Re: i don't understand footstep for 2d actor
Post by: dreamfighter on May 11, 2008, 02:50:43 PM
Thank you menmonic i checked a new time step by step and my error was the } at the end of my script like said net. thank you net for this details.
it 's very cool that working thank you both


About this engine, my opinion is wintermute is the very best engine that i found on the web, really and it's free.
Thank you for that mnemonic.