# Problems with rudimentary projectile motion

**URL:** https://forum.kirupa.com/t/problems-with-rudimentary-projectile-motion/218095
**Category:** flash
**Created:** [March 5, 2007, 2:05am UTC](https://forum.kirupa.com/t/problems-with-rudimentary-projectile-motion/218095 "2007-03-05T02:05:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Vexir](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vexir](https://forum.kirupa.com/u/Vexir)
#### Post date: [March 5, 2007, 2:05am UTC](https://forum.kirupa.com/t/problems-with-rudimentary-projectile-motion/218095/1 "2007-03-05T02:05:21Z")

</div>

I have no idea what is wrong with this. Honestly. The \_y of Bush goes above \_root.\_height and still it does not stop animating. It starts out initially at a height that comes from god knows where. This was supposed to be easy ☹

```auto
var simulate:Boolean = false;
var initialheight:Number;
var currentheight:Number;
var angle:Number;
var initialvelocity:Number;
var currentxvelocity:Number;
var currentyvelocity:Number;
var initialxvelocity:Number;
var initialyvelocity:Number;
var currenttime:Number;
var currentframe:Number = 0;
var framerate:Number = 30;
var g:Number = 9.81;

simulate_btn.onRelease = function() {
	if (velocityinput.text != 0) {
		initialvelocity = velocityinput.text;
		angle = stepper.value;
		initialheight = initialheightinput.text;
		initialheight = _root._height - initialheight;
		bush_mc._y = initialheight;
		currentxvelocity = Math.cos(angle) * initialvelocity;
		currentyvelocity = Math.sin(angle) * initialvelocity;
		initialxvelocity = Math.cos(angle) * initialvelocity;
		initialyvelocity = Math.sin(angle) * initialvelocity;
		
		simulate = true;
	}
}

onEnterFrame = function() {
	if (simulate == true) {
		currentframe++;
		currentvelocitytext = currentxvelocity / Math.cos(angle);
		currenttime = currentframe / framerate;
		if (bush_mc._y < _root._height) {
		bush_mc._y = _root._height - (initialheight + initialyvelocity*currenttime + (.5 * (-1 * g) * (currenttime * currenttime)));
		bush_mc._x = currenttime * currentxvelocity;
		}
	}
}

```

FLA:

[http://vexiron.com/physicsproject.fla](http://vexiron.com/physicsproject.fla)
