ID:151873
 
Ok I know this has been discussed (a lot) before. But I was searching through the forums and all information is really old and theres a lot of different answers all with little pros and cons to each.

So I figured I get a topic to see what everyone thought was the best way to control movement speed and also have the best animation with it.

The two main ways i have seen are modifying either client/Move() or mob/Move() and then either using a time delay or a variable to check for movement. Like below
client//or mob
Move()
if(world.time < mob.move_time)
return
mob.move_time = world.time + mob.move_delay
return ..()
Move()
if(mob.moving)
return
mob.moving=1
spawn(2) mob.moving=0
return..()

So Ive noticed a couple things with this. With client move if your delay is more than 2 or 3 your key gets registered as being released and you go in and out of movement state for your movement. As for using mob/Move you have delays with all movement and not just user input.

Are there any other ideas for movement and what is the best one in your opinion.

Sorry if this seems like a old topic but with the release of 4.0 (and not seeing much addressed in it since '06) I figured with all the interface features and macros and updates maybe there was something better out there that no one has shared with the rest of us.
You can use a list containing all the directions pressed, and move using that list. I actually just wrote one for someone:
mob/var
tmp/moving = 0
rundelay = 3 //Set this to different settings to control how slow the mob walks.
client/var/list/movequeue
client/Move(NewLoc,dir)
if(!movequeue||!movequeue.len)movequeue=list()
movequeue+=dir
if(!mob.moving)
mob.moving=1
while(movequeue.len)
mob.Move(get_step(mob,movequeue[1]))
movequeue-=movequeue[1]
var/d=mob.rundelay
if(movequeue.len>d){mob.icon_state="run";d-=2} //"run" = Running icon state, 2 is how much delay is taken off when running
else mob.icon_state="" //normal icon state the mob has
sleep(max(1,d))
if(!movequeue.len)
movequeue=null
mob.moving=0
In response to Kaiochao
oh thats pretty cool and you even have it to where it will turn to a run if held down.
In response to Kaiochao
This is very cool, helped me out. Small question, would it be possible to set it so you can only "run" if you have the skill? IE(" if(run == 1) ") Or somthing ?
In response to Carnia
...Yes. Just put the if() above the part where it checks for running.