Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Trying to mix and mingle 3d physics with the Unity UI

Discussion in 'Physics' started by zero_null, Nov 15, 2018.

  1. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    I have recently created a drag drop system where I drag stuff from a UI menu and then drop it to another UI. The child of the draggable UI object is a 3d model. I have attached box collider and rigidbody to this 3d object and moving the Object with rigibody.MovePosition and rigidbody.MoveRotation. The object doesn't respond to physics like if there is a box collider in the way, it just goes through it without showing any physical reactions.
    I wanted to know if I can do this mixing of Unity UI which helped me in creating this drag drop and also helped scaling the UI and the 3d physics engine to get my job done.
    My Project is basically an interactable toy train system where user will create a track and run the carts on it.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,022
    That's the expected behavior. MovePosition and MoveRotation just force the rigidbody to do that, no matter the physics interactions. They are mostly intended to be used with kinematic rigidbodies.

    You have to use rigidbody.AddForce and rigidbody.AddTorque if you want the object to have physical reactions. Check out the different ForceMode options, which allows you to add an amount of velocity but still interact with other objects.
     
    zero_null likes this.
unityunity