How to contain a gameObject inside a collider?


I’m trying to create something similar to googly eyes.

I would like to create a polygon collider with a sphere INSIDE.
It would be like an eyeball inside an eye rotating according to physics.

However unity sees the polygon collider as a surface and not as a boundary,
So the eyeball is being pushed out from the eye.


Check this thread Sphere collider invert? - Unity Answers.

@mt2020 @agora I was looking for the answer everywhere but I realized that we were over complicating the action. You can create a Googely eye effect without having to use physics at all. Here’s what I did.

  1. Create a transform outside of the head hierarchy.
  2. Center it in the middle of the head
  3. Name it “Pivot” . This will serve as the pivot for our eyes.
  4. Now Parent the eyeballs (pupils) to that transform, so that they inherit the movement and rotation.
  5. Add this script to the Pivot transform.

public class LerpEyeRotation : MonoBehaviour
    public Transform target;
    public float speed = 10F;

	void Update () {
		transform.rotation = Quaternion.Lerp(transform.rotation, target.rotation, Time.deltaTime * speed);
	    transform.position = target.position;
  1. Make the target the head.
  2. Celebrate