Removing Rigidbody Constraints

Hello, I have added the DragControls.ts script to some objects, but I would like them to fall when they hit or are placed on the edge of the table.How could I achieve that?

Original Post on Discord

by user 328144332622266369

On the DragControls you could register via addDragEventListener to drag end and drive the rigidbody contraints there :+1:

It looks like the rigidbodies are sleeping/not waking up after drag ends :thinking:

You can try to call wakeUp on the Rigidbody via the addDragEventListener as suggested to test if that’s the problem

I`ve tried what you suggested, but no luck. There is still something that prevents the objects to tip over. I want to work like the objects from this sample Needle Engine Samples. I explored it but I couldn’t manage to find the difference.

by user 328144332622266369

do they have a rotation constraint? looks like they always keep their orientation.

by user 395602247196737546

In Unity, they have no constraints activated. The center of mass is set okay, I’m thinking that something applies a rotation constraint when I lift them?

by user 328144332622266369

Hm, it doesn’t seem to.

It also seems, that there is a interface IDragEventListener which you can implement in your script, there you can

console.log(this.gameObject.getComponent(Rigidbody))

And see the state of the rigidbody

I’ve tried what you recommended yesterday, but it worked just one time. After that there was no chance to find where to put that line again, so it will display something when I press the play button. Unfortunately, I can’t manage to make any kind of code to work inside DragControls.ts. I was trying also to add some angular motion to the objects, without succeeding. Any ideas why it doesn’t want to work?

by user 328144332622266369

The basic physics sample works like you would like it to right? Needle Engine Samples
20230621-162451_Needle_Engine_Samples_-_Google_Chrome-logo.mp4

I think it also just uses drag controls without custom code. Perhaps you can take a look at this one again and compare with your scene?

Eventually, I managed to make it work. It was about box colliders and physics material. I had mesh colliders and for some reason it didn’t want to work. Thank you all!

by user 328144332622266369

Mesh collider on the object or on the map?

Glad that you figured it out :+1:

On the objects. For the map I used box colliders from the beginning.

by user 328144332622266369

Ok, last thing, was the mesh collider set to convex?