dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: rope and swing.

  1. #1
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140

    rope and swing.

    I'm having some trouble figuring out the trig for coding a rope between two objects.
    What i've got so far is hardly trig. It looks completly wrong. I've searched the forums on "swing", "rope", everything i've found needs to rotate the swinging object.
    However i don't want my object to rotate. Imagine an invisible rope between two objects.

    I hope someone can help, even with a tutorial. Thanks
    Last edited by mr_malee; 10-07-2005 at 05:22 AM.
    lather yourself up with soap - soap arcade

  2. #2
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    anyone?
    lather yourself up with soap - soap arcade

  3. #3
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    I'm kind of confused as to what you're getting at, like a stiff, board-like rope or a rope that has physics and acts realistically?

    And what do you mean by invisible rope?
    Last edited by OpethRockr55; 10-08-2005 at 03:19 AM.

  4. #4
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    a rope which has physics
    lather yourself up with soap - soap arcade

  5. #5
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    I would use Verlet Integration. Attached is an example.

    This way, you could easily add MC's, say a person or a hook, to the desired joint in the rope and have it rotate with the rope and move with the physics of the rope.
    Attached Files Attached Files

  6. #6
    Senior Member mbenney's Avatar
    Join Date
    Mar 2001
    Posts
    2,744
    there was an opensource ninja rope file around here not so long ago.

  7. #7
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    found something that drunkenMaster2000 did, it seemed like he had the same problem, but he solved it by modifying the clips _x and _y positions, i need to however modify the object velocity. This is what i have now, its basically a spring. My rope needs to rotate around a point in a circular motion
    code:

    //r is the rope
    var xd:Number = r._x-_x;
    var yd:Number = r._y-_y;
    var inertia:Number = .98;
    var k:Number = .005;
    x = x*inertia+xd*k;
    y = y*inertia+yd*k;

    lather yourself up with soap - soap arcade

  8. #8
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    This is exactly the effect i want.

    http://members.optushome.com.au/chrisrhodes/swing.html
    lather yourself up with soap - soap arcade

  9. #9
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    ok to simplify the question, i require an object to rotate around a point while adhering to the laws of motion - gravity, acceleration, deceleration. Much like a swinging rope or pendulum (however with the pendulum all code i've found rotates the object, i require code without rotation).


    I have searched not only on these forums but everywhere else. You would not believe how hard it is to find a simple solution to my problem. I know one must exist because you can rotate an object around a point at a constant speed at a set raduis using this simple code:
    code:

    radius = 100;
    degree++
    angle = degree*(Math.PI/180);
    x = radius*Math.cos(angle);
    y = radius*Math.sin(angle);
    man._x = _xmouse+x
    man._y = _ymouse+y


    Please help.
    Last edited by mr_malee; 10-12-2005 at 12:16 PM.
    lather yourself up with soap - soap arcade

  10. #10
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    First, find the velocity of the thing moving by subtracting the old coordinates from, say, a frame ago and store that in a variable.

    Then, change that variable using your own specifications, like adding 3 pixels every frame if the a key is down or adding gravity, mass, etc.

    After that, add those to the current coordinates and you have physics driven motion.

    This method could, logically, work in the rotation of an object too, only exchange the coordinates for the degrees of rotation and you should get the same effect.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center