Hollow Ball Movement and Collider

Hello. My goal is to have a hollow transparent ball that can be controlled with WSAD. Inside that sphere, there would be a capsule object of height = 2x sphere radius. I want the capsule to move along with the sphere as shown in the screenshots. To create the hollow sphere I used ProBuilder. I’ve flipped the normals of the Sphere object and then used the Set Collider option of ProBuilder. The first issue I encountered is that the mesh collider of the sphere does not work (It just falls off the map) unless I make the sphere rigid body kinematic. I cannot understand why is this happening. When I make it kinematic, it holds the capsule object inside as I wanted and doesn’t fall off the map, but then I don’t know how to control the movement of that sphere. (I’ve tried transform.Translate and transform.Rotate but the result is ball flying around. I am new to Unity and this is my first project. I would appreciate any suggestions/pointers from you guys. Thank you :slight_smile:

—> Screenshots

Hello, assuming this capsule has fixed position inside the sphere (like embedded in amber) you don’t need collider for the capsule as it’s purely visual thing. If you put it inside other object it will rotate and move with it anyway.

It is better if you use sphere collider instead of mesh collider, it’s not only better optimized, but also it’s actually sphere, not polygon with many faces. I do not know your setup, but object that move need rigidbody and it’s normal they fall down with gravity. It should not be kinematic as you want it to be part of simulation.

I am going to assume there is some ground to collide with, so why it does not work? I guess it’s fault of your mesh collider and there are two resons. If you use mesh as rigidbody it must be marked as convex, otherwise it will not work and second is probably caused by inverted normals. Normals of mesh are used to determine face direction used by physics, for example if you put huge plane collider upside down, everything is going to pass through it.

Bonus: Sliding a Sphere

Thank you for your answer. I find it extremely helpful. Your first point is something I didn’t think of before. I will definitely have to try it out. You are right about the rigidbody, if I mark it as convex, then the mesh collider starts to work and it interacts with other objects. Unfortunately, the capsule pops out from the sphere in that case.

The idea of a capsule-sphere object came to my mind when I struggled to implement a smooth movement for the capsule. Imagine the capsule is the character that the player can control. If I move forward or back from the standing position, it rotates nicely around the x-axis (see the screenshots). However, when the capsule falls on its longer side, and I want to move left or right, it just rolls like a rolling pin which is not what I want. I thought of putting the capsule in a sphere, making the sphere invisible and the capsule static would solve my problem and smoothen the movement in any direction.

—> Screenshots

Rigidbodies repel each other. As I said you don’t need collider and rigidbody for capsule, but if you needed more complex shape you can create compound collider by adding one rigidbody on top of hierarchy.

If you put object as child it will move with the parent, so you can’t make static capsule inside sphere without additional script to correct rotation. What you actually want is to not allow capsule to fall. Rigidbody has constraints and you can freeze rotation and translation on given axis. Anyway I think you should start with some character tutorial if that is your goal - there is plenty on youtube.