Search Unity

Infinite pendulum

Discussion in 'Physics' started by cedart, Jul 8, 2015.

  1. cedart

    cedart

    Joined:
    Jul 10, 2014
    Posts:
    17
    Hi,

    I would like to make an infinite pendulum, a perpetual motion, with 2d physics.
    I have 2 rigid body and a distance joint. When I play game, all is ok.



    I just want to know if the motion is perpetual ?
    Looks like yes but maybe after a while ...

    If not, do you have an other technic ?

    Thanks :)
     

    Attached Files:

  2. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    The easiest version if you don't need to change the amplitude strength by a float would probably be: animate it in a loop. that way it will be perpetual for sure.

    Another way would be not to use physics but Lerp (or iTween from the AssetStore) to animate the pendulum.
     
  3. cedart

    cedart

    Joined:
    Jul 10, 2014
    Posts:
    17
    The loop is a good idea. I think I'll use that :)

    Another question comes : i'm trying to link the two sides of the pendulum by a simple rope. Not necessary a very realistic rope, just a simple line. I thought I could use line renderer but I can't :/ Do you have a solution ?

    Thanks you so much :)
     
  4. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    If you are going to animate it, anyways (and you have the ressources in your scene) why not model and rig the rope?
    If it's not going to bend or look sort of floppy, then you don't even need to rig it. Just animate it with the pivot at the base of the rope. If you want to use a linerenderer it should be justified.

    Simply a pendulum on a straight rope sounds easy enough to me that I'd just model and animate it as an object instead of a line renderer.
    Or rig and animate it with bones if it's going to look more elaborate.
     
  5. cedart

    cedart

    Joined:
    Jul 10, 2014
    Posts:
    17
    Oh ok. But if I have only one animated object, can I attach an other sprite at the end ?

    I will try this, thanks :)
     
  6. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    If you are using 2D you can simply create a sprite and add a pendulum/swingblade/whatever as a child object at the end. I've made a quick example file to show what I mean. Switch the rope and/or the ball with sprites as you see fit.

    Read through the documentation about graphics and parent/child relationships to get further information. Also maybe work through a few of the 2D tutorials to get into how to think in game terms and setups. :)
     

    Attached Files:

  7. r0gerg

    r0gerg

    Joined:
    Mar 24, 2014
    Posts:
    2