having a few problemd with this.
I want my player when he has stopped walking to be still for a few secs then go in to his idle animation.
whats happening is the timer is working but then I get a rapid burst of animation( like its just playing one frame or something) then it goes back to the still sequence.
what should happen is that the idle animtion should loop until you exit the idle state.
Its probably real obvious that i am a bit out of my depth here, but I need to get it wokring
delayTime=1500 ; 1 1/2 secs
time_to_wait=millisecs()+delayTime ; use 0 for no initial delay
Function UpdatePlayer( p.Player )
walkstate=False
If KeyDown(200) ;walk forward
walkstate=True
MoveEntity p\entity,0,0,.2
If Animating(p\model)=p\walk
Animate p\model,3,.7,1
EndIf
EndIf
;Walking back
If KeyDown(208)
walkstate=True
MoveEntity p\entity,0,0,-.2
If Animating(p\model)=p\walk
Animate p\model,3,-.7
EndIf
EndIf
If KeyDown(203) ; left/right
TurnEntity p\entity,0,2,0 ;turn player left/right
Else If KeyDown(205)
TurnEntity p\entity,0,-2,0
EndIf
;stopped
If walkstate=False
stopstate=True
Animate p\model,1,0,2,5;play no animation to simluate stop before entering idle state
If MilliSecs()>=time_to_wait
If Animating(p\model)=p\idle;idle animation
Animate p\model,3,.2,2;play idle animation after delay
time_to_wait=MilliSecs()+delayTime
End If
EndIf
EndIf
;footstep cycles
If KeyDown(200) Or KeyDown(208)
p\footStepCycle=p\footStepCycle+0.5
Else
p\footStepCycle=0
EndIf
If p\footStepCycle=11.0
PlaySound footsteps
p\footStepCycle=0
EndIf
I tried to use the code darlordz gave me for the timer , but I don't really understand it to be honest
I want my player when he has stopped walking to be still for a few secs then go in to his idle animation.
whats happening is the timer is working but then I get a rapid burst of animation( like its just playing one frame or something) then it goes back to the still sequence.
what should happen is that the idle animtion should loop until you exit the idle state.
Its probably real obvious that i am a bit out of my depth here, but I need to get it wokring
delayTime=1500 ; 1 1/2 secs
time_to_wait=millisecs()+delayTime ; use 0 for no initial delay
Function UpdatePlayer( p.Player )
walkstate=False
If KeyDown(200) ;walk forward
walkstate=True
MoveEntity p\entity,0,0,.2
If Animating(p\model)=p\walk
Animate p\model,3,.7,1
EndIf
EndIf
;Walking back
If KeyDown(208)
walkstate=True
MoveEntity p\entity,0,0,-.2
If Animating(p\model)=p\walk
Animate p\model,3,-.7
EndIf
EndIf
If KeyDown(203) ; left/right
TurnEntity p\entity,0,2,0 ;turn player left/right
Else If KeyDown(205)
TurnEntity p\entity,0,-2,0
EndIf
;stopped
If walkstate=False
stopstate=True
Animate p\model,1,0,2,5;play no animation to simluate stop before entering idle state
If MilliSecs()>=time_to_wait
If Animating(p\model)=p\idle;idle animation
Animate p\model,3,.2,2;play idle animation after delay
time_to_wait=MilliSecs()+delayTime
End If
EndIf
EndIf
;footstep cycles
If KeyDown(200) Or KeyDown(208)
p\footStepCycle=p\footStepCycle+0.5
Else
p\footStepCycle=0
EndIf
If p\footStepCycle=11.0
PlaySound footsteps
p\footStepCycle=0
EndIf
I tried to use the code darlordz gave me for the timer , but I don't really understand it to be honest