How to set custom RigidbodyConstraints?

Hello,

I still have my issue with the particles and the sphere.
See 1 for question.
However I’ve decided to try it from a different perspective and not use the fixedjoint which doesn’t give me the results I want.

So now I’m gonna try and keep the particle in position. For this I (think I) need the rigidbody.constraints.

The particles constraints start with the following settings for constraints
freeze position x(false) y (false) z(true)
freeze rotation x (true) y (true) z(false) // this ensures 2d movement

after it hits the sphere it should remain in it’s position, but it should still move a bit like it’s wiggling or something.
So I would like to set the constraints to
freeze position x(true) y(true) z(true)
freeze rotation x(true) y(true) z(false)

Debug.Log returns 56 with the initial setting.
Changing it to one of the prefixed settings would return that enum.

How to set the constraints to a custom setting?

And how to change it back, because they will only stick to each other for about 3 seconds…

It’s all there in the docs for Rigidbody.constraints. You use bitwise OR | to specify which dimensions to constrain, and any you don’t specify will be unconstrained. You can store the current constraints in a RigidbodyConstraints type, then reinstate them when you’re finished.

RigidbodyConstraints previousConstraints = rigidbody.constraints;
rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;  // Constrain only on X and Y rotation axis
// ... later ...
rigidbody.constraints = previousConstraints; // set to previous state

In your case you can also pre calculate the set of constraints you want to apply (all positions and X and Y rotations locked):

private RigidbodyConstraints wiggling = RidigBodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;

Edit: changed from int type to RigidbodyConstraints type for storing the constraints.