Search Unity

How to apply backward force (deacceleration) on rolling sphere

Discussion in 'Scripting' started by unikum, Mar 23, 2011.

  1. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    Since the sphere is rolling, I can't use vector.back as I understand it.

    Can I figure out the direction the sphere is going and apply a force in the opposite direction? The sphere is rolling around in all possible direction on uneven terrain.
     
  2. Darloc

    Darloc

    Joined:
    Feb 16, 2011
    Posts:
    167
    you could just increase the drag on the rigedbody
     
  3. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    I've been experimenting with drag, but can't get it to behave like I want to. The force added has to be a constant force (depending on slope angle). Like 0.02 in the opposite direction that it is traveling. It's the rolling friction force that I'm trying to add to it. I have the force for the ball calculated when it's rolling around, I just need to know how I can apply it in the opposite direction that it is traveling.

    I'm really bad at this stuff. If I have the last position and the current position, don't I know what direction it is traveling? If so, how do I use it to apply a force in the other direction?
     
  4. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Angular drag is pretty much the rolling friction. Normal friction has almost no effect because the contact areas are so small.
     
  5. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    But since I have the correct rolling friction calculated, isn't it better to apply that than using angular drag that is only "pretty much rolling friction"? I'm doing a simulation of a golf ball, so it has to behave correctly.
     
  6. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
  7. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    Aaaargh, I can't get this to work.

    If I use Angular drag, I can't make it stop in slopes above a certain angle. Doesn't matter how high the angular drag and normal drag is set to. It just moves very slowly in a constant speed. If the slop simulates a slope with high grass, the ball should stop even if the slope is pretty steep.

    And when I try to apply a force backward it always end up going back and forward, I can't find the exact force needed to completely stop the object (like in hovering air, where you can just add negative mass * gravity).

    Anyone know how to solve this? I'm going crazy trying to fix this...


    Or is there a way to cheat to get this to work (I'm that desperate) so that I can force the ball to sleep when moving slowly? Problem is that I can't set it to sleep just based on velocity since it might roll up a very steep hill, come to a stop more or less, and then roll down again. It should only stop if it has been moving slowly for a certain time I guess, would I set a timer to trigger this? This seems messy.