# Crazy Movement Problem

**URL:** https://forum.kirupa.com/t/crazy-movement-problem/316760
**Category:** flash
**Created:** [December 1, 2010, 8:53pm UTC](https://forum.kirupa.com/t/crazy-movement-problem/316760 "2010-12-01T20:53:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rimacy](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rimacy](https://forum.kirupa.com/u/rimacy)
#### Post date: [December 1, 2010, 8:53pm UTC](https://forum.kirupa.com/t/crazy-movement-problem/316760/1 "2010-12-01T20:53:25Z")

</div>

I’m trying to get a ship to move with a thruster and retain its velocity

here’s the code

```auto
package
{
    import flash.display.Sprite;
    
    public class Ship extends Sprite
    {
        ;
        var thrust:Number=0;
        var xVel:Number=0;
        var yVel:Number=0;
        var xAcc:Number=0;
        var yAcc:Number=0;
        var gravity:Number=1;
        var rVel:Number=0;
        var lVel:Number=0;
        
        
        public function Ship():void
        {
            
        }
        public function moveShip():void
        {
            rotation = rVel;//rVel is controlled by left and right keyPress
            var angle:Number=rotation*Math.PI/180;
            trace("angle Is " + angle);
            xAcc=Math.cos(angle) * thrust;
            yAcc=Math.sin(angle) * thrust;
            xVel+=xAcc;
            yVel+=yAcc
            x=xVel;
            y=yVel;
            trace(rVel);
            trace("xVel="+ xVel)
            trace("yVel="+ yVel)
            trace("move ship");
            trace("thrust= " + thrust);
            
        }

```

the trace statements show a change in X velocity and that X velocity doesn’t return to 0  
on the screen the ship will ONLY move like the thruster is mounted on the left side(pushing it right) and will not retain it’s velocity(it will only move each time i hit the thruster).  
What am I doing wrong here?? It looks right to me.
