Some help with b3d animations, please?
Blitz3D Forums/Blitz3D Programming/Some help with b3d animations, please?
| ||
heyo, I'm having some trouble with changing animations [between Idle, Walk and Run]. My code is a follows: This works fine, but all it does is animates an Idle animation when standing still and walking when [W] is depressed. I tried to add a third sequence with: This doesn't work, it changes between animations but doesn't stop animating when the button is released. I also tried to add a variable "seq%" in my For/next loop where I animate the root node. eg. but altering the "seq%" outside of the function didn't change the animseq. And if I tried to put "If Keydown()" in the function I get an error. Any Help would be appreciated. Any Ideas? |
| ||
Hello, I don't have time to correct your code but i used these commands, this way : ;to load the animations of the character : HumanMaleXMesh = LoadAnimMesh("Cosmonaut MaterialedRiggedAnimated 2012.04.03 14h49m.b3d") ScaleEntity(HumanMaleXMesh,0.099,0.099,0.099) PositionEntity(HumanMaleXMesh,0,0,0) HideEntity(HumanMaleXMesh) Global HumanMaleSeqStandIdle = ExtractAnimSeq(HumanMaleXMesh,1,1) Global HumanMaleSeqRunForward = ExtractAnimSeq(HumanMaleXMesh,5,21) Global HumanMaleSeqRunBackWard = ExtractAnimSeq(HumanMaleXMesh,5,21) Global HumanMaleSeqJump = ExtractAnimSeq(HumanMaleXMesh,39,43) Global HumanMaleSeqFall = ExtractAnimSeq(HumanMaleXMesh,43,43) ;Global HumanMaleSeqLandGravityLow = ExtractAnimSeq(HumanMaleXMesh,43,66) Global HumanMaleSeqLand = ExtractAnimSeq(HumanMaleXMesh,43,66) ;Global HumanMaleSeqLandGravityHigh = ExtractAnimSeq(HumanMaleXMesh,43,66) Global HumanMaleSeqPickUpItem = ExtractAnimSeq(HumanMaleXMesh,43,66) ;to init the different possible states : ;PositionState Const OnGround% = 30 Const OnAir% = 31 Const OnWall% = 32 ;MovementState ; OnGround Const Idle% = 40 Const WalkForward% = 41 Const WalkBackward% = 42 Const RunForward% = 43 Const RunBackward% = 44 ;Const SprintForward% = 45 ;Const SprintBackward% = 46 ;Const CrouchForward% = 47 ;Const CrouchBackward% = 48 ;Const SlideForward% = 49 ;Const SlideBackward% = 50 Const Jump% = 51 ;Const Interact% = 52 ;(interuptor, Handle, furniture, Object, weapon, device, vehicle, character) ;Const Fight% = 53 ; OnAir Const Fall% = 54 Const Land% = 55 ;(slow, average, fast) ; OnWall Const Grab% = 56 ;(knee height, hip height, shoulder height, hands above head height) Const Climb% = 57 ;(flat platform,ladder, grid, net, gouti�re, poteau, trunk, rope, cable) Const Letgo% = 58 ;to update the animations depending on the character state: For ChaId% = 1 To CharactersCount% If(CharacterPositionState%(ChaId%) = OnWall%) ; ElseIf(CharacterPositionState%(ChaId%) = OnGround%) RotateEntity(CharacterFeet(ChaId%),0,CharacterYaw#(ChaId%),0) If(CharacterMovementState%(ChaId%) = Idle%) CharacterMovementSpeed#(ChaId%) = 0 ;Seq StandIdle If(AnimSeq(CharacterMesh(ChaId%)) <> HumanMaleSeqStandIdle) Animate(CharacterMesh(ChaId%),1,0.1*SpeedCoeff#,HumanMaleSeqStandIdle) EndIf ElseIf(CharacterMovementState%(ChaId%) = RunForward%) CharacterMovementSpeed#(ChaId%) = 0.1*SpeedCoeff# ;Seq RunForward If(AnimSeq(CharacterMesh(ChaId%)) <> HumanMaleSeqRunForward) Animate(CharacterMesh(ChaId%),1,0.2*SpeedCoeff#,HumanMaleSeqRunForward) EndIf ElseIf(CharacterMovementState%(ChaId%) = RunBackward%) CharacterMovementSpeed#(ChaId%) = -0.1*SpeedCoeff# ;Seq RunBackward If(AnimSeq(CharacterMesh(ChaId%)) <> HumanMaleSeqRunBackward) Animate(CharacterMesh(ChaId%),1,0.2*SpeedCoeff#,HumanMaleSeqRunBackward) EndIf ElseIf(CharacterMovementState%(ChaId%) = Jump%) CharacterJumpState%(ChaId%) = 1 CharacterJumpSpeed#(ChaId%) = 0.2*SpeedCoeff# ;Seq Jump If(AnimSeq(CharacterMesh(ChaId%)) <> HumanMaleSeqJump) Animate(CharacterMesh(ChaId%),3,0.2*SpeedCoeff#,HumanMaleSeqJump) EndIf ElseIf(CharacterMovementState%(PId%) = Land%) ;Seq Land If(AnimSeq(CharacterMesh(ChaId%)) <> HumanMaleSeqLand) Animate(CharacterMesh(ChaId%),3,1.0*SpeedCoeff#,HumanMaleSeqLand) EndIf If(AnimTime(CharacterMesh(ChaId%)) = 23) CharacterLandState%(ChaId%) = 0 EndIf EndIf ElseIf(CharacterPositionState%(ChaId%) = OnAir%) TranslateEntity(CharacterFeet(ChaId%),CharacterVX#(ChaId%),0,CharacterVZ#(ChaId%)) CharacterGravitySpeed#(ChaId%) = CharacterGravitySpeed#(ChaId%) - Gravity#*SpeedCoeff# CharacterVY#(ChaId%) = CharacterJumpSpeed#(ChaId%) + CharacterGravitySpeed#(ChaId%) TranslateEntity(CharacterFeet(ChaId%),0,CharacterVY#(ChaId%),0) ;Seq Fall If(AnimSeq(CharacterMesh(ChaId%)) <> HumanMaleSeqFall) Animate(CharacterMesh(ChaId%),3,1.0*SpeedCoeff#,HumanMaleSeqFall) EndIf EndIf Next Please note this is an old code, so it can probably be improved but maybe it can help you. PS : forget about the symbols "%" "#" "$", they are needed only when you create a new variable but not everywhere like in this code, this is an old bad habit that i had. Last edited 2013 |