Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Oscillating Springy Cubes

Discussion in 'Physics' started by Replik8tr, Jan 4, 2015.

  1. Replik8tr


    Mar 2, 2014
    I am scribbling out my concept for a self assembling spring system. Just wanted to get any thoughts, pointers, or strategies. Please see the attached scribbles.

    The user would place different types of "cubes" snapped to a 3d grid. This would happen in an editor level. (Paused at zero time) This part is easy and has lots of tutorials for Minecraft.

    This is where it gets more interesting.
    The user created cubes would be saved and loaded into the simulation level.
    The cubes will not be rendered. The center of each cube would be found.

    Springs would be created between each center and its neighboring centers. I am calculating spring forces directly, not using the built in spring joints in the editor. F=kX.

    Certain cube types are oscillators, causing the attached springs to expand then contract.

    Neighbors are calculated once in Start. This keeps the springs from getting too disordered. [Could be interesting to update the neighbors for gelatinous fog type behaviour/ polarized assembly]

    The centers without full neighbors are on the outside and are used as the vertices for rendering meshes at run time.

    In Start
    For each center:
    Get Neighbors;

    In FixedUpdate
    For each neighbor:
    Get Distance
    Get Direction
    Calculate forces (Spring force, drag, expansion force)
    Apply forces

    Scribble22.jpg Scribble11.jpg
  2. TiG


    Feb 28, 2011
    It seems you are figuring everything quite well. Good luck
  3. Replik8tr


    Mar 2, 2014
    Coming along. I've been trying a few things.

    Decided to shoot bullets at neighbor cubes to trigger.

    The shoot script is working to shoot repeatedly from the oscillator cube. The projectiles shoot out orthogonal from the center of each face. Working on getting the projectiles to trigger the neighbors.

    Spring forces resulted in a puddle of strange magnets. Attracting each other at distance and repulsing each other close up. Seems that some of the cubes would stop reacting to the repulsion force leading to large lumps of cubes.

    Tried JellyMesh asset. Very nice Jelly physics right on what I'm trying to do. Haven't gotten them to stick properly yet. (Because of my lack of skill, the asset is great) Will try this further. Went back to standard cubes for now.

    I'm using Sticky Stick Stuck now to keep the cubes together. Using transform.scale to expand and contract the cubes.
    I think some physics forces need to be added to go with the scale transform.

    Still very early, have to do whole user interface. Get physics working right.
    Make sure I'm not trying to script things that are built in. :)