walk animation

Blitz3D Forums/Blitz3D Beginners Area/walk animation

Sorry guys, but here's another stupid question. I want to make a player controlled character walk, but I can't get it to stop walking when it stops moving and resume walking when it's moving again.

This
sorta helped me, and don't forget to check the Manuals!

Now he starts to walk if I change the anim and press the run button, but he doesn't stop...never mind, that topic got it

Just some basics:

You need some kind of multiple stage handling:
if Walking key pressed
 if walking=0
  walking=1
  animate walkloop with smooth transition
 endif
else
 if walking=1
  walking=0
  animate idleloop with smooth transition
 endif
endif

additionally you may use a variable walking speed

if walking=1
 if walkspeed#<1.0 then walkspeed#=walkspeed# + 0.1
endif

if walking=0
 if walkspeed#>0.0 then walkspeed#=walkspeed# - 0.1
endif

moveentity character,0,0,walkspeed#


From the Castel demo...

	
If KeyDown(203)	;left/right
		TurnEntity p\entity,0,6,0	;turn player left/right
	Else If KeyDown(205)
		TurnEntity p\entity,0,-6,0
	EndIf
	
	If KeyDown(30)		;forward
		If p\anim_speed<=0
			p\anim_speed=1.75
			Animate p\model,1,p\anim_speed
		EndIf
		MoveEntity p\entity,0,0,1
	Else If KeyDown(44)	;back
		If p\anim_speed>=0
			p\anim_speed=-1.75
			Animate p\model,1,p\anim_speed
		EndIf
		MoveEntity p\entity,0,0,-1
	Else If p\anim_speed	;stop animating
		p\anim_speed=0
		Animate p\model,0
	EndIf