Reputation: 11
So I'm making a 2d top down game and one of my enemies is supposed to be a tank. I have two separate sprites for this tank, one for the tracks/body and one and for the turret. I want to have one game object contain both of these sprites. I would just combine them into one sprite but I want to have the turret rotate itself to face the player using a script I wrote while keeping the tracks pointed in the direction the tank is moving. Is this possible? I'm new to Unity but, I cant think of another way to accomplish this goal.
Upvotes: 1
Views: 4158
Reputation: 2586
A good way to do this would be have a parent game object A with two children game objects B and C. B can have a sprite for base and C can have a sprite for the top. You can then rotate each game object individually and can still use gameObject.GetComponent(). To move the tank move the parent.
Upvotes: 3