Rolling circle hero with stationary eyes

Hey Everyon,

I’m working on a 2D platform game where the hero is a ball. I’d like his body to roll as he moves around, so I have CircleCollider2D attached with a ridgidbody2D. The hero has a set of eyes that shouldn’t rotate, but follow the hero around. When I make the eyes a child of the hero, the eyes roll with the body.

I could manually set the location of the eyes in Update() but that’s seems very inefficient. I was hoping someone would have a better way.

60448-ref.png

Contain both the eyes and body in another empty game object and give this parent object a reference to the body. Then you can control the horizontal/vertical motion using the parent object and just apply the rotation to the body reference.

Ultimately you have no choice but to ‘detach’ the eyes from the body. In effect you are asking for them to move ‘independently’ of the body, which is what detaching means!

You could just manually set the eyes each frame, though you might be able to make your life a little easier by placing them (and any other none rotating details) in a seperate game object that is centred in the same way as the body (i.e. if you give both the body object and your ‘details’ object the same transform, the overlay perfectly).

That way all you will ever have to do is set your ‘details’ object to have the same transform.position as your body object, and everything else will ‘just work’.

-Chris

(EDIT: which is exactly what @LazyElephant just suggested - sorry - should have read other answers first!).