# Character movement

**URL:** https://forum.kirupa.com/t/character-movement/87147
**Category:** programming
**Created:** [April 18, 2005, 8:21pm UTC](https://forum.kirupa.com/t/character-movement/87147 "2005-04-18T20:21:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ar1](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@ar1](https://forum.kirupa.com/u/ar1)
#### Post date: [April 18, 2005, 8:21pm UTC](https://forum.kirupa.com/t/character-movement/87147/1 "2005-04-18T20:21:10Z")

</div>

Hey people. I’m trying to get something done with character movements, but I can’t seem to get something right. Using the if (Key.isDown) things doesn’t seem right, and has a few glitches.

I’m trying to have it to where when I press up, down, left or right, the character moves in that direction, but when you press up and right, for example, to go diagonal, I don’t want the other codes interfering with it.

For example, this is the code that I started off with:

```auto

onClipEvent (enterFrame) {
    
    speed1 = 4
    speed1a = 2.8
    
    if (Key.isDown(Key.RIGHT)) {
        this.gotoAndStop (4)
        _x+= speed1
    }
    
    if (Key.isDown(Key.LEFT)) {
        this.gotoAndStop (3)
        _x-= speed1
    }
    
    if (Key.isDown(Key.UP)) {
        this.gotoAndStop (2)
        _y-= speed1
    }
    
    if (Key.isDown(Key.DOWN)) {
        this.gotoAndStop (1)
        _y+= speed1
    }
}

```

speed1 is the normal speed, and speed 1a is the speed that I want the character to move with diagonaly. I just can’t seem to get it right, using different methods, I can’t get it. Could someone help me out?

Thanks[color=DeepSkyBlue]

!GB! - PEACE -  
[/color]
