Wednesday, April 18, 2012

Walk/Run state

Does anyone know a way to poll the walk/run state?

I've read through all the events/widgets but turned up nothing obvious.|||Not that I know of. It doesn't have an event associated with it or anything of that sort so to the best of my knowledge there's no way to check.|||The way to do it is with a trick. You would need to create a frame that would update every .05 seconds (or .1 seconds). Inside this frame, you would have an OnUpdate function that will store your previous map coordinates and your new map coordinates. Subtract the smaller value from the largest value for the X coords and do the same for the Y coords. Then, add the two together, and then multiply the result by 10000 to get a very generic "speed" value, in the ball park of 0 and 80. If you're going less than 35, you're walking. If you're going more than 35, you're running. If your "current x" and "previous x" coordinates are the same, and your "current y" and "previous y" coordinates are the same, you're standing. If you are in an instance, you can't get map coords, so just ignore instances.

Doing this, I can determine if I'm running, walking, or standing. Throw in another check to see if you're mounted and if so, say you're "Mounted" instead or walking or running.

It can be done, but it's very gritty and can give wrong results *sometimes* ... especially if you are running backward. You might come up as walking or running, depending on the angle you're going.

Of course, knowing the angle you're moving, you could probably calculate the speed that way, but I'm not going into that :)

No comments:

Post a Comment