Loop animation 5 times then stop?
Blitz3D Forums/Blitz3D Beginners Area/Loop animation 5 times then stop?
| ||
I made an animation in milkshape and in blitz I want the animation to play 3 or for times and then stop until the player collides with it and then play 3 or 4 times again. So far all I can get is if the player collided then the animation does not play or if the player collided then the animation plays forever What is a way to get it to play 5 times then stop? |
| ||
Well, when you animate, look at using the one-shot animation flag (animate once only), with the Animate command. Then check to see if the entity is still animating with the Animating command. Something like this i'd imagine: [code] counter=0 While Not Keyhit(1) If counter<=3 then If Animating(entity)=false Then Animate entity,3 ; one shot animation. counter=counter+1 End If End If UpdateWorld RenderWorld Flip Wend End |
| ||
Ok so I tried that but it did not work correctly, better but still not right. So I chaneged some things. here is what I did... ;if players < 12 player is in range ;if players in range (pir) then pir = true distance# = EntityDistance# ( player,Sting) If distance# < 12 Then pir = True Else pir = False EndIf PointEntity Sting,camera PointEntity Sting2,camera PointEntity Sting3,camera ; Then here when player is in range the animation should ;start but instead it pauses and then continues only when ;pir = 0. ie players out or range. If pir = True And distance# < 25 Then Animate Sting,pir,.4,0,1 Animate Sting2,pir,.6,0,1 Animate Sting3,pir,.5,0,1 EndIf If distance# > 25 Then Animate Sting,0,.4,0,10 Animate Sting2,0,.6,0,10 Animate Sting3,0,.5,0,10 End If It just would not make sence for a giant scorpian tail stiking out of the ground to wait till your out of range to strike. Could this be a bug? ha ha get it? bug? |
| ||
You don't seem to have the counter variable i did, to animate it five times. And your not checking to see if the entity is still animating either. |
| ||
"You don't seem to have the counter variable i did, to animate it five times" Acualy I did try it. But it wasn't working and just now I tried it again and what happens is the animation just keeps playing even before the player has come anywhere near it. I have changed the collision check from a collition box to a math check (pir) player in range. And now I just want it to be on/off.If the player is in range play the animation until the player is out of range. |
| ||
Its a funny thing that,when all the conditions for the animation to play are true and that it does not animate till the conditions are false. |
| ||
So I have made some ajustments to an example program to more acuretly desribe the problem. It needs no models to be loaded so it will work on your machine. I think that the problem is that the animation is restarting on the first frame with each iteration of the main loop. So blitz does not see the problem and we dont see an animation. All I did is place the animation in a if statment. If *keyhit* space bar then anim. This works If *keydown* space bar then anim. This does not work because it is restarting with each loop until you release the spacebar. So it is exactly what is happening in My program. The animation starts over and over when condition pir = true but will not complete the animation until (pir) 0r keydown space bar = false. Please try it. If we can get this program to work so that as long as keydown space bar = true then animate 1 time then check if animation is done, then check if condition is still true,and if it is play animation again ect...ect...I am sure I can get MY program to work the same way. |
| ||
anybody? |
| ||
have u globaled the counter variable? |
| ||
I got It figured out. thanks anyhow. It was so easy! And I make things so complicated! if keydown(57) = true and animating(ball) = false then animate ball,3,0,0,0 endif |