Wintermute Engine Forum

Wintermute Engine => Bug reports => Not a bug => Topic started by: ronin on January 07, 2009, 01:24:41 PM

Title: Minor Bug: Actor's walk animation is reset when clicking at the same/another pos
Post by: ronin on January 07, 2009, 01:24:41 PM
During evaluating version 1.8.8 (Beta) of the WME i made some tests with the actor movement/animation and tried some things a player probably never would do, but can do.
I noticed that if the player continuously clicks at the same position the actor's animation always restarts from beginning while walking to this position. This also happens if the player clicks on another position while the actor is already walking but does not change the direction.

The first problem can be dealt with for example by extending the "scene.script" like this
Code: WME Script
  1. #include "scripts\base.inc"
  2. actor.LastX = -1000; // an init value which is different from a valid position value
  3. actor.LastY = -1000; // an init value which is different from a valid position value
  4. ////////////////////////////////////////////////////////////////////////////////
  5. on "LeftClick"
  6. {
  7.     // when the scene is left-clicked, just send the actor to the specified point
  8.     // if the actor is not already walking to it.
  9.     if (actor.LastX != Scene.MouseX || actor.LastY != Scene.MouseY)
  10.     {
  11.         actor.LastX = Scene.MouseX;
  12.         actor.LastY = Scene.MouseY;
  13.         actor.GoTo(Scene.MouseX, Scene.MouseY);
  14.     }
  15. }
  16.  

The second problem can be weakend by defining a dead zone
Code: WME Script
  1. #include "scripts\base.inc"
  2. var diff;
  3. actor.LastX = -1000; // an init value which is different from a valid position value
  4. actor.LastY = -1000; // an init value which is different from a valid position value
  5. ////////////////////////////////////////////////////////////////////////////////
  6. on "LeftClick"
  7. {
  8.     // when the scene is left-clicked, just send the actor to the specified point
  9.     // if the actor is not already to a point near it.
  10.     diff.x = Math.Abs(actor.LastX - Scene.MouseX);
  11.     diff.y = Math.Abs(actor.LastY - Scene.MouseY);
  12.     if ( diff.x > 50 ||  diff.y > 20) // experimental values for the dead zone
  13.     {
  14.         actor.LastX = Scene.MouseX;
  15.         actor.LastY = Scene.MouseY;
  16.         actor.GoTo(Scene.MouseX, Scene.MouseY);
  17.     }
  18. }
  19.  

But this solution looks a bit dirty to me. Therefore it might be helpful if the engine itself could take care of these cases.
Title: Re: Minor Bug: Actor's walk animation is reset when clicking at the same/another pos
Post by: Mnemonic on January 07, 2009, 10:47:53 PM
Just for the record, 3D actors already provide this feature (via actor.GoToTolerance property). 2D actors don't.
Title: Re: Minor Bug: Actor's walk animation is reset when clicking at the same/another
Post by: ronin on January 07, 2009, 11:18:30 PM
It is good to know that this features is available for 3D characters.

But if i decide to use 2D character is there a better way to avoid or weaken this problem than the one i have posted before?

Is this feature planned for 2D characters in WME 1.X?
Title: Re: Minor Bug: Actor's walk animation is reset when clicking at the same/another pos
Post by: Mnemonic on January 07, 2009, 11:24:37 PM
I think the "dead-zone" solution is ok (it's basically what the GoToTolerance does internally). Perhaps a more elegant solution would be to override the GoTo method instead of modifying the LeftClick handler.

IMO the first script is unnecessary though. The animation doesn't restart if you send the actor to exactly the same point.
Title: Re: Minor Bug: Actor's walk animation is reset when clicking at the same/another
Post by: ronin on January 07, 2009, 11:36:50 PM
Alright. Thanks for your quick response. :)