At 7/24/08 07:54 PM, LesPaulPlayer wrote:
At 7/24/08 07:22 PM, mayoarm11 wrote:
I only have two more orange squares left on my tree (turrets that I need to do).
LesPaulPlayer: I decided not to do the grappling hook thing. It's a good idea, but it will require a rope thing. when it hooks, it will be attached to the unit by a rope. The AS for making the rope physics is, obviously, possible to make, but is hard. I don't want to spend an entire week scripting a rope for one turret. =/
ok maybe not a week. but at least 2-3 days.
It's not that bad. what you need to do is have the enemy apply a force depending on the angle connecting the turret and the enemy (distance is not relevant as long as you assume constant tension). Then you have some code like this:
var angle:Number = Math.atan2(enemy.y-turret.y,enemy.x-turr et.x)
var fx:Number = Math.cos(angle)*2
var fy:Number = Math.sin(angle)*2
turret.vx += fx
turret.vy += fy
turret.x += turret.vx
turret.y += turret.vy
turret.vx *= .9
turret.vy *= .9
That should probably get a good effect for the rope, but if you don't want to use it you don't have to.
wouldn't that make the rope completely straight all the time. Like... just a line?
oh yeah reread your post (constant tension). See what I wanted was a rope like you see in the tortoure game 2
that bends n shit. Straight line kinda rope is really easy to make, but it looks kinda weird.
Idk, I'll leave this to the end. If I have time, I'll try scripting the rope like it should look like. And if I dont have enough time, but still need more turrets, I'll do straight line thing.
Your code wouldn't work in all cases, as it doesn't take into consideration the rope's length;
The idea I had in mind for making a straight line rope is:
the rope's length is changed in an enterframe function using pythagorean theorem.
Then, only once the rope reaches a certain length, let's say 100 pixels, then the turret rotates to face the enenmy unit, and starts rolling in the enemy's speed towards it.
This way, false tension is created. But the thing is, with a real rope, before the 100 pixels are reached, the rope wouldn't be straight, it'd be all loopy. But idk, I guess it doesn't matter that much.
K I'll do it :)
sweet idea, thnx. I'll get to it right away. I'll show you the result if you want.