Search Unity

How to make a rotating plane rotate an object sitting on it

Discussion in 'Physics' started by NEVER-SETTLE, Jan 14, 2019.

  1. NEVER-SETTLE

    NEVER-SETTLE

    Joined:
    Apr 22, 2018
    Posts:
    30
    Hi!

    I'm trying to make the car (or anything) in the video rotate when on the plane or inside the tube.
    What I've tried so far:
    - putting a Physics Material on the tube & plane but has no effect
    - tuning the parameters of the Physics Material, no effect
    - marking the animation's Update Mode of the tube and plane as "Animate Physics", no effect
    - increasing the traction of the car (uses RCC), no effect
    - increasing the mass of the car..nothing
    - increasing mass of wheels, nothing
    - for the cube I tried changing mass and drag, no changes
    - tried googling the problem, either didn't write the right terms or just couldn't find anything

    Any help would be appreciated.
    Thanks!


     
  2. canis

    canis

    Joined:
    Oct 25, 2013
    Posts:
    79
    A)
    if your "car" is run by physic you may able to do it by adding "joint" on the tire.
    joint can be broken under certain amount of force (or distance)
    so the force can be append on the car, before it break, to drag some else base on the movement.

    B)
    there is some other way like, set the "Car" transform.parent to the moving platform to do the trick.
    since the parent movement also affect on child objects.
    but I doubt if it help (test it ~).

    C)
    however my personal suggestion is complete wipe out physic (I'm also working on it.)
    totally control the "Car" by script movement.
    I was able to doing something like this by following code. (shallow)

    To detect the platform movement & rotation different between fixedUpdate.
    assume you cache it (e.g. m_PlatformData)
    Code (CSharp):
    1.  
    2. rotateDiff = Quaternion.FromToRotation(m_PlatformData.lastGroundRotation * Vector3.forward, ground.transform.rotation * Vector3.forward);
    3.  
    4. Vector3 from = m_PlatformData.lastAvatarPosition;
    5. Vector3 to = ground.transform.TransformPoint(m_PlatformData.relatedPosition);
    6. posDiff = to - from;
    therefore, you can apply the additional movement based on the platform movement in your movement script.
    e.g.
    Code (CSharp):
    1. if (isPlatformMoved)
    2. {
    3.     nextPos += platformMove;
    4.     if (platformRotate != Quaternion.identity)
    5.     {
    6.         Vector3 localRot = platformRotate * Vector3.forward;
    7.         localRot = Vector3.ProjectOnPlane(localRot, avatar.BiasGroundNormal);
    8.         Quaternion lhs = Quaternion.LookRotation(localRot, avatar.BiasGroundNormal);
    9.         Quaternion rhs = Quaternion.LookRotation(nextFacing, avatar.BiasGroundNormal);
    10.         Quaternion final = lhs * rhs;
    11.         nextFacing = final * Vector3.forward;
    12.     }
    13. }
    PS: the solution may not perfect, welcome for discussion.

    the result is here.
     
    Last edited: Jan 14, 2019
  3. NEVER-SETTLE

    NEVER-SETTLE

    Joined:
    Apr 22, 2018
    Posts:
    30
    Thanks a lot for the tips !

    A) It uses a framework, adding things would mean tweaking a lot of other things
    B) Your doubts are correct :)
    C) That's interesting what you've did there, but would be way too time consuming for my case

    I got an answer on Stackoverflow for who's interested

    1. If you have an animation that rotates the plane, delete it.
    2. Add a Rigidbody to the plane and lock the axes you don't want rotated
    3. Add a Constant Force on the axis you want rotated
    4. ???
    5. Profit :D
     
  4. canis

    canis

    Joined:
    Oct 25, 2013
    Posts:
    79
    Interesting how can you achieve that without coding ?
    2 & 3 look like rotate the tube on z-axis by adding constant force.

    if I understand correctly you wanted the car stick on the tube's inner surface based on the rotation.
    (Correct me if I'm wrong),

    although I don't think there is the way to do it without coding.
    however if you can do it without coding please let us know. :)
     
  5. NEVER-SETTLE

    NEVER-SETTLE

    Joined:
    Apr 22, 2018
    Posts:
    30
    Not stick, just act as it would under normal gravity. In reality that plane would rotate your car and even throw it off the plane if the rotation is fast enough. In reality that tube would turn your car around and at some point would flip your car over. That's what the steps above do. I already have it implemented