Animation of Mesh Not Looping
Blitz3D Forums/Blitz3D Beginners Area/Animation of Mesh Not Looping
| ||
Hello, I just got into blitz3d and I have a .3ds file. It loads just fine, and does the animation loop only once, even though I have it set to loop. So I'm a bit confused as to what is going on here. Here is my code: Edit: Obviously this is just very basic code loading and positioning a 3D mesh and running the animation sequence in a loop. That's about all I'm trying to accomplish with this code sample. |
| ||
see if changing the transition works try setting the transition to 0 the transition is between animations like walk to run not for looping i think Animate entity[,mode][,speed#][,sequence][,transition#] Animate man (1 , 0.1 , 0 , 0) |
| ||
Ok well I changed the code to the following and it does load the mesh and animate it in a loop: But now I'm trying to figure out how to start the animation when I press a key and to have it stop when I release the key and I'm having problems figuring that one out. I tried adding: If KeyDown(31) Walking_Anim() EndIf But that didn't do anything. It won't animate at all. What I was trying to do was make it so that when you press the S key (which corresponds to the WASD movement set up) it would start animating. If I change the code to: If KeyDown(31) = False Walking_Anim() EndIf Then it animates in a continous loop. But if I press the S key, it doesn't stop anything. Any ideas? |
| ||
That won't work, because when your holding down the key, your telling it to animate everyframe, so it's starting from the first frame all the time. You need a flag of some sort, or: If keydown(31) then If AnimSeq(entity) <> 2 then Walking_Anim() End if Else Standing_Anim() ; or whatever you want to do when not animating End If That should sort you out. Your checking to see if the entity is animating sequence 2 (your walking animation sequence). If it isn't, then your telling it to animate. If the key isn't being held down, your telling it to animate the standing animation (or just tell it to stop if you don't have a standing animation). |
| ||
If KeyDown(31) sequence = 2 else sequence = 1 endif select sequence case 1 ; IDLE If AnimSeq(entity) <> sequence Animate entity, 1, .2, sequence, 10 case 2 ; RUN If AnimSeq(entity) <> sequence Animate entity, 1, .2, sequence, 10 ;case 3 ;case 4 ;case 5 ;AND SO ON ;ADD AS MANY AS YOU WANT end select |
| ||
That would be a better solution :o) That's whats good about these boards. |
| ||
Well I got it to work! Thanks guys! :) I used a combination of select case and a flag. Here is what I did: This code properly displays the idle animation when the key isn't being held and properly loops the animation when the key is held down! Yay! |