# I just made my game character crouch, ..sorta.. The animation doesn't work!

**URL:** <https://forum.kirupa.com/t/i-just-made-my-game-character-crouch-sorta-the-animation-doesnt-work/222688>\
**Category:** programming\
**Created:** [April 16, 2007, 7:43am UTC](https://forum.kirupa.com/t/i-just-made-my-game-character-crouch-sorta-the-animation-doesnt-work/222688 "2007-04-16T07:43:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jiruharudo](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@Jiruharudo](https://forum.kirupa.com/u/Jiruharudo)\
**Post date:** [April 16, 2007, 7:43am UTC](https://forum.kirupa.com/t/i-just-made-my-game-character-crouch-sorta-the-animation-doesnt-work/222688/1 "2007-04-16T07:43:56Z")

</div>

'Lo to all who their time to read this.  
[COLOR=gray]_Thanks for your time. ^^_[/COLOR]

[COLOR=black]I’ve been working on a little game,[/COLOR]

[COLOR=black][http://media.putfile.com/Game-by-Gerhard[/COLOR]](http://media.putfile.com/Game-by-Gerhard%5B/COLOR%5D)

Yesterday someone commented that I should make the character crouch, because…  
“It would be awesome.”

So I figured, “heck, why not? :)”  
I started looking the code and came up with the following concept;

///// start code for crouching and horizontal movement /////  
**[COLOR=green]if (Key.isDown(\_root.CROUCHKEY)) {[/COLOR]**  
//if the player is pushing the crouch key  
**[COLOR=green]if (\_root.mcPLAYER.GROUNDED == true) {[/COLOR]**  
//if the player is grounded  
**[COLOR=green]if (\_root.mcPLAYER.DIRECTION == “R”) {[/COLOR]**  
//if the player is facing right  
**[COLOR=green]\_root.mcPLAYER.gotoAndPlay(8);[/COLOR]**  
//show the player crouching facing right frame  
**[COLOR=red]//This is where the fun starts (test: making crouch)[/COLOR]**  
**[COLOR=green]if (Key.isDown(\_root.RUNRIGHTKEY)) {[/COLOR]**  
//if the player is trying to move right aswell, he should start **crouching**  
**[COLOR=green]\_root.mcPLAYER.XMOVEMENT += 0.1;[/COLOR]**  
//set the player momentup to go right slowly  
**[COLOR=green]\_root.mcPLAYER.gotoAndStop(11);[/COLOR]**  
//this SHOULD make crouch animation go  
**[COLOR=green]}[/COLOR]**  
**[COLOR=#ff0000]//This is where the fun ends (test: making crouch)[/COLOR]**  
**[COLOR=green]} else {[/COLOR]**  
//if the player is facing left  
**[COLOR=green]\_root.mcPLAYER.gotoAndStop(9);[/COLOR]**  
//show the player crouching facing left frame  
**[COLOR=green]}[/COLOR]**  
**[COLOR=green]}[/COLOR]**  
**[COLOR=green]} else {[/COLOR]**  
//if the player isnt crouching  
**[COLOR=green]if (Key.isDown(\_root.RUNRIGHTKEY)) {[/COLOR]**  
//if the player is trying to move right  
**[COLOR=green]\_root.mcPLAYER.XMOVEMENT += 1;[/COLOR]**  
//set the player momentup to go right some  
**[COLOR=green]\_root.mcPLAYER.DIRECTION = “R”;[/COLOR]**  
//make the player face right  
**[COLOR=green]}[/COLOR]**  
**[COLOR=green]if (Key.isDown(\_root.RUNLEFTKEY)) {[/COLOR]**  
//if the player is trying to move left  
**[COLOR=green]\_root.mcPLAYER.XMOVEMENT -= 1;[/COLOR]**  
//set the player momentup to go left some  
**[COLOR=green]\_root.mcPLAYER.DIRECTION = “L”;[/COLOR]**  
//make the player face left  
**[COLOR=green]}[/COLOR]**  
**[COLOR=green]}[/COLOR]**  
///// end code for crouching and horizontal movement /////  
///// End code that runs every frame /////

It works, sorta.  
It does show frame 11, and it’s even moving slowly… BUT it’s lacking it’s animation!

_[COLOR=silver]Dramatic theme[/COLOR]_

Which made me think of my previous problem:

[COLOR=seagreen]**onClipEvent(load){**[/COLOR]  
**[COLOR=seagreen]startTime = getTimer() + 3000;[/COLOR]**  
**[COLOR=seagreen]}[/COLOR]**  
**[COLOR=seagreen]onClipEvent(enterFrame) {[/COLOR]**  
**[COLOR=seagreen]currentTime = startTime - getTimer();[/COLOR]**  
**[COLOR=seagreen]countDownClock = currentTime/1000;[/COLOR]**  
**[COLOR=seagreen]if (currentTime \<= 0) {[/COLOR]**  
**[COLOR=seagreen]gotoAndPlay(10);[/COLOR]** _[COLOR=silver](or \_root.mcPLAYER.gotoAndStop(10); )[/COLOR]_  
[COLOR=seagreen] **}** [/COLOR]  
**[COLOR=seagreen]}[/COLOR]**

Which made the animation stop, instead of going to the frame 10…

For some reason, my walking code **DOES** show an animation…  
I did put the whole animation in a one frame movieclip, so that couldn’t be it.

[COLOR=silver]_Could it…?_[/COLOR]

In any case, help would be appreciated like woa…  
_[COLOR=gray]Because this is getting a real downer… x.x;[/COLOR]_
