Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Minor Bug: Actor's walk animation is reset when clicking at the same/another pos  (Read 9630 times)

0 Members and 1 Guest are viewing this topic.

ronin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile

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.
« Last Edit: January 08, 2009, 10:06:46 AM by ronin »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site

Just for the record, 3D actors already provide this feature (via actor.GoToTolerance property). 2D actors don't.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

ronin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile

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?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site

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.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

ronin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile

Alright. Thanks for your quick response. :)
Logged
 

Page created in 0.03 seconds with 24 queries.