Search Unity

Creating a Sticky Physic Material

Discussion in 'Editor & General Support' started by CavemanLog, Jun 2, 2009.

Thread Status:
Not open for further replies.
  1. CavemanLog

    CavemanLog

    Joined:
    Mar 25, 2009
    Posts:
    12
    I want to create a physic material, (or equivalent), that will allow an object to stick to a surface. Ideally I would like it to stick, but move at a VERY slow rate. I've tried static and dynamic friction levels, as well as upping drag, but none help the material "stick" naturally and still suffer effects from gravity. Thanks guys!
     
    Psyco92 likes this.
  2. G3David

    G3David

    Joined:
    Oct 1, 2007
    Posts:
    35
    what i would suggest doing is make a script for your object, whenever it collides with(you could filter based on physics material by comparing the others collider.sharedPhysicsMaterial) and store the currect drag and angular drag of the object and increase it however you wish, and when it comes off of the object(no longer is colliding with, etc) you revert back to the old drag and
    angular drag

    var drag
    var angdrag
    private var olddrag
    private var oldangdrag
    function OnCollisionStay(other : collider)
    {
    olddrag=rigidbody.drag
    oldangdrag =rigidbody.angulardrag
    rigidbody.drag=drag
    rigidbody.angulardrag=angdrag
    }
    function OnCollisionExit(other: collider)
    {
    rigidbody.drag=oldDrag;
    rigidbody.angulardrag=oldangulardrag
    }
    etc
    didnt put in code quotation cause its half-phsuedo code
     
  3. Psyco92

    Psyco92

    Joined:
    Nov 15, 2013
    Posts:
    22
    I am in the same situation, and drag control is not an option due to the nature of the scenario.
    nor is that an ideal solution.

    I have a sticky physic material (lots of friction, no bounce) and force in the direction i wish to stick (a wall), but the object tens to slide around and move on the wall a little bit, more so with gravity on.

    Is there any way to have a rigidbody be able to completely resist being dragged along another collider?
     
Thread Status:
Not open for further replies.