Character animation
Blitz3D Forums/Blitz3D Beginners Area/Character animation
| ||
Hi, I downloaded that animated dwarf mesh from psionic, and I studied the code, on how to animate it. That is all good. However, whenever I want to use the running animation when i am moving forward, tried this: ;move character forward If KeyDown( 200 )=True Then MoveEntity char,0,0,.08 ;animate character while moving forward If KeyDown( 200 )=True Then Animate char,1,.2,seq,1 And while i was holding the up arrow, he froze in the air with his legs apart, so i took my finger off of the arrow key, and he was running. I would like to know how to animate a character while moving forward. It is probably obvious but... Also, No matter how many times I checked the entityradius, and stuff, he has been floating about 0,1,0 above the ground Is it a problem w/ the mesh? I kinda dismissed that, since, this psionic guy looks like he knows what he is doing. Any help would be great! |
| ||
The problem is that you are triggering the Animate command over and over; that is restarting the animation each time, so it looks like it is stuck at the beginning. Use the command AnimSeq to only start the animation if it isn't already in the animation. Also, you don't need to do If KeyDown(200) twice, just put it all inside one If statement: If KeyDown(200) MoveEntity blah If AnimSeq()<>seq Animate blah End If As for the EntityRadius, you have to bear in mind that the radius is from the origin point of the model. Psionic is probably setting his character's feet at the origin point (this is how most people animate, with their character walking on the base grid of the animation tool) so you will need to raise up the origin point for EntityRadius, probably by attaching the dwarf to a pivot and using that pivot for collision detection. |
| ||
'not enough parameters' Here is the code involving my animmesh The error is on the animseq line char=LoadAnimMesh("dwarf2.b3d") chartex=LoadTexture("dwarf2.jpg") PositionEntity char,-50,6,120 ScaleEntity char,.085,.085,.085 EntityType char,Player ExtractAnimSeq char, 16, 26 seq=1 If KeyDown(200) MoveEntity char,0,0,.08 If AnimSeq()<>seq Animate char,1,.2,seq,1 End If |
| ||
You gotta put in the name of the entity to check. So AnimSeq(char) Make sure to look up commands in the command reference so that you know how they are used. |
| ||
Ok, my guy is on the ground, cool :) but: If KeyDown(200) MoveEntity char,0,0,.08 If AnimSeq( char )<>seq Animate char,1,.2,seq,1 End If I used this code, while he does not stop, while i am holding the button, he does not stop animating after i release the arrow key. I am so sorry for being thick =( |
| ||
The animation will keep going until you tell it to stop/switch to a different one. So you need code that'll call the Animate command with a different animation sequence when the button isn't being held:If KeyDown(blah) blah Else Animate blah End If |
| ||
How do I choose which animation to use per thing right now, here is the code for him to move. ;idle ExtractAnimSeq char, 292, 325 ;run ExtractAnimSeq char, 16, 26 seq=1 While Not KeyDown( 1 ) ;jump If KeyHit( 57 )=True Then TranslateEntity char,0,9,0 ;speed boost If KeyDown( 16 )=True Then MoveEntity char,0,0,9 ; Controls If KeyDown( 203 )=True Then TurnEntity char,0,1,0 If KeyDown( 205 )=True Then TurnEntity char,0,-1,0 ;move character forward and animate If KeyDown(200) MoveEntity char,0,0,.1 If AnimSeq( char )<>seq Animate char,1,.2,seq,1 End If I have extracted the animation for the dwarf to be idle, now he is just idle, when I push the button to walk. Thank you for all you have done so far, I hopefully only need a little more of your time. |
| ||
Okay, first off you aren't ever changing the seq variable. It's set to 1 and never changes, so later on when you use it you are telling the Animate command to use the first animation sequence. However, your first animation sequence is the idle; running is the second animation sequence (the sequences are numbered in the order that you extract them.) Thus you need to change that value to 2, or just plain type 2 instead of seq. Second, you still aren't doing that Else bit I mentioned. To switch between running and idle, call Animate on sequence 2 for running and sequence 1 for idle. Here's the code for what I describe, examine it carefully and look up all of the commands being used (Animate, AnimSeq, ExtractAnimSeq) so that you understand exactly how this works: If KeyDown(200) MoveEntity char,0,0,.1 If AnimSeq(char)<>2 Animate char,1,.2,2,1 Else If AnimSeq(char)<>1 Animate char,1,.2,1,1 EndIf |
| ||
Thanks! You rock! Sorry For being such an idiot about things. I am new to programming as a whole, and am trying desperately to get my mind around it. |