3
$\begingroup$

I have a project that needs to give 2D physics to a 3D object. Here's essentially what I'm trying to create.

This 3D cube (I squashed its scale to look like a plane), should be able to translate and rotate in 3D space, but there is a circle that can only translate on the surface of one face of the 3D cube. However, if the cube rotates around, the circle should move following the gravity of the world. This is sort of like an accelerometer display or a pinball machine.

This is what I'm trying to achieve:

One of the constraints that I'm facing is that:

  1. The circle should never leave the cube's surface
  2. The circle needs to have mass
  3. The circle needs to collide with the edges

However, I'm struggling to find the necessary tools in Blender 3.0.1 that can achieve this. Does anyone have any ideas?

$\endgroup$

2 Answers 2

8
$\begingroup$

Sure. You want it acting like a pinball machine, and pinball machines are 3D, so it shouldn't be a problem. We'll just use non-rendering physics:

enter image description here

We'll start with six boxes, forming the walls of our box, all parented to a central empty to control it. These six boxes all have animated, box collision, rigid body physics. All but one of them are disabled in renders. (Here, I've also changed some to wireframe display in the viewport.)

We put a ball in there. It gets rigid body physics as well, although dynamic, not animated, and sphere collision. Likewise, it is disabled in renders.

Finally, we make the rendering circle. It is parented to the same empty as the boxes, so it acquires their rotation, but it has a copy location constraint targeting the sphere. In case the sphere jumps, because we want a little tolerance for the box, we also shrinkwrap to the rendering plane.

There would be plenty of other ways to do this as well, ranging from rendering the circle in material nodes instead of giving it a mesh, to actually projecting the physics ball onto the plane after rigid body physics gets us the transform, via shrinkwrap modifier or geometry nodes.

$\endgroup$
1
  • 1
    $\begingroup$ Brilliant! I absolutely love the creativity! $\endgroup$ Commented Feb 7, 2022 at 20:17
0
$\begingroup$

I wish there was a way to use a 2D simulation which should be faster.

My take here is to use a rigid body constraint to limit the Z movement to 0. The ball doesn't roll, because there's no floor for it to roll... In a way, this directly answers the question for 2D simulation, where a circle wouldn't roll either, though I understand this is probably not actually what OP wants :)

Rigid Body Constraint

Create an empty, In Physics Properties add Rigid Body Constraint, Type: Generic, Disable Collisions unchecked , Limits > Linear > Z Axis from 0 to 0:

And Objects:

  1. First object - some passive rigid body that stays in place - In my case I just used the collider (and that's why I don't disable collisions)
  2. Second object - the ball.

Parent everything to another empty and rotate that empty to control the plane:

$\endgroup$
3
  • 1
    $\begingroup$ As for rotating around, it's absolutely possible, as scene's gravity vector can be driven, but understandably it's not very convenient (not without a somewhat complex setup at least where it would maybe depend based on camera perspective? 🤔 ) $\endgroup$ Commented Feb 7, 2022 at 20:52
  • $\begingroup$ Ignore the above comment, I changed the answer to use default gravity... As for the roll... I could write a Python script that automatically adds the correct roll to the sphere... 🤔 I guess it would be tricky to decide if it should roll based on touching a side wall or a floor... $\endgroup$ Commented Feb 7, 2022 at 22:00
  • $\begingroup$ but you know you can delete comments...do you? ;) $\endgroup$
    – Chris
    Commented Feb 8, 2022 at 7:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .