Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Cargo Transportation Problem

Discussion in 'Physics' started by denizluleci, Jul 29, 2018.

  1. denizluleci

    denizluleci

    Joined:
    May 30, 2016
    Posts:
    7
    Hello,

    I do have a problem about transportation of a box in moving truck. Both of my objects (truck and cube) has rigidbody and other neccessary compenents (colliders, wheel colliders, box colliders etc). The problem is, if I start moving my truck, cube just stays where it is and when it crash to behind of truck it moves in container. I need a relative velocity. So for example if a bus moves in 80km/h while you are sitting or standing in the bus, also you move with it. Only in sudden movements, your position may change.

    In the game, I do have enough friction (static and dynamic combined). I have also tried it with several joints, but I could not get a good result. Would you please clarify a way me to solve it? Is there any script for that or, do I have to use combined joints? I have also tried fixed and spring joint, but results are not well.

    Best Regards,
    Deniz
     
  2. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    296
    Last edited: Jul 30, 2018
  3. denizluleci

    denizluleci

    Joined:
    May 30, 2016
    Posts:
    7
    No the problem is not asleep. Ok I try to tell it like this:
    If I put a box in a moving platform (with a ridigbody), platform moves but my cube does not move with platform. I want cube to move with platform without making parenting. If I make the platform as parent, it is Ok cube moves with platform but does not apply some physics features. For example, if platform stops suddenly, cube stops suddenly too. But If you are in a car, and if car stops suddenly, you will move to forward a little bit. When parenting, phyiscs loses some feautees (like acceleration). Is there any way to solve it with some joints or etc?

    Thanks
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,584
    The behavior you describe, is exactly as colliders in asleep mode.
     
  5. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    296
    Try this:
    Change your cube for a sphere.
    If the sphere behaves just like the cube, I would think it is a sleep problem.
    If the sphere behaves as you would expect, then the problem is a friction problem.

    I have tried myself. The cube with not physic material behaves as you say. If I add it a "ice" physic material, it works.

    I hope it helps
     

    Attached Files:

    • ice.png
      ice.png
      File size:
      19.2 KB
      Views:
      978
  6. denizluleci

    denizluleci

    Joined:
    May 30, 2016
    Posts:
    7
    Actually I tried all of them, physical material did not help it, I tried high friction-low friction, it is not the solution, also I have used rigidbody in WakeUp() method, it is not the solution too.

    Here is another aspect: image you have a pen over your book. and you hover your book 1 meter, if you do it slow enough, your pencil will move with your book and it will not lose the connection with your book. but image you suddenly hover up your book with (80km speed) and stop your book suddenly. maybe your pencil will move upper about few cm from over your book because of the accleration of speed. (I am sorry for my english, I try my best to tell the problem).

    So for the cargo game: my truck is getting acceleration, if I do it very fast, cubes should slide and I stop suddenly, cubes must crash the container's front side. but friction did not help it, I tried it in many ways. When I rotate the object rotation works well, cubes slide but acceleration does not work so good, so my question is do I need to write code for this situation, for example if breakForce > 100f then cube.applyForce(100f) like that? or are there any other option like joints?

    By the way I thank you so much for your help.
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,584
    Out of interest, what if you try force object to wake up, when you move the platform?
     
  8. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    296
    No, you shouldn't have to write code to get this behaviour. Maybe for more complicated behaviours you should, but for having a inertia acceleration, you should have it for free by the physics engine.

    I am sorry I can't help you more, but I have tried your situation and I do have the correct behaviour
     
  9. ElektronLibre

    ElektronLibre

    Joined:
    Jan 6, 2018
    Posts:
    1
    Hello, I dig up this topic.
    I have the same problem as you @denizluleci, did you find a solution? if yes can you share it?

    In my case, I'm in virtual reality and I want to carry objects in a box.
     
    Last edited: Dec 2, 2021
  10. GadOleg

    GadOleg

    Joined:
    Nov 13, 2019
    Posts:
    52
    We need to make the cargo a child object
     
  11. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,676
    How are you moving the truck's rigidbody? If you're not using rigidbody.MovePosition, rigidbody.velocity, or AddForce() (but setting transform.position instead) the truck will have no velocity and as a result, velocity-based features (like friction) won't work at all.