Can I have multiple sprites on one game object in Unity? - unity3d

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.

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.

Related

Is it possible to have collision on a child object moves its parent in Unity?

I'm attempting to develop a 2.5D fighting game in Unity, and I've gotten to the point of attempting to make basic collision between players function. I'm attempting to do so via collision boxes like those seen in the video here: (4:01 if the timestamp doesn't work)
https://youtu.be/m5yRLhAx4Ro?t=241
What I have attempted to do in order to replicate this system of collision is to make a collision box prefab with a dynamic rigidbody and box collider. A script instantiates a new one as a child of the player and destroys any existing ones whenever the collision box's size and position need to be changed. However, I've found that this does not work. I can get the players to collide with each other, but when I disable that collision by putting the parents on a layer that doesn't collide with any others, the collision boxes themselves will just phase through each other along with their parent objects, the players.
What I want is a system in which the players will be responsible for their movement, but the child objects (the collision boxes) will function as the players' colliders. If anyone knows a way of doing this, or any other way of achieving this sort of system, I would greatly appreciate the help.
Just add a Fixed Joint on the child object then connect it with the parent rigidbody.

How to make an object follow the movements of an animated object in Unity?

So I've animated my spaceship. With it's previous rigid form I've got a particle system coming out of it's wings. Now that it's animated, I still want those particles to follow all of it's wings movements, but the particles don't move along with the animations, even being parented with the gameobject's wings, showcase video, 19seconds: https://youtu.be/XJNjT4s4X6I
How can I make those particles move along with it's wings movements? Thanks
I would try to parent them with the bone of the armature, I don't remember if it worked for me though, but what I did is to add an empty in the modeling program to follow the animation and export it, so I can parent it to the things I needed, for you It would be the Particle System.

How can I remove small part of collider of game object in unity 2d

click here for gif show of what I want
I want to remove mesh of object when user click on object and also remove its collider to make another object fall from that removed mesh area...
I am using unity since last month so I don't have much experience and knowledge, please help me...
Creating the destructable ground particles
One way to achieve whats shown in the gif is by creating a prefab of e.g. a circle collider that is instantiated in the area of where the dirt is in your gif. It acts as a "ground particle" and keeps the objects above itself.
You instantiate a lot of them in the area so it acts as a big collider although it is actually a whole array of smaller colliders.
Implementing the interaction logic and deactivating the ground particles
Ater that you implement the functionality of dragging the mouse over the ground particles, removing them. That is also not difficult. Shoot raycasts into the screen at the postition of the mouse (remember to use Camera.ScreenToWorldPoint) and get the collision information (confer to https://docs.unity3d.com/ScriptReference/Collider2D.Raycast.html). With the collision information you can get the reference to the instance of your ground particle(raycasthit.other.gameobject) which is then disabled through script(gameobject.setActive(false)).

Is it possible to merge two sprites in Unity?

I am making a 2d customizable character. I want to go with sprite based animations. So I have created different parts that can be customized. For example eyes can be swapped by different types of eyes by just changing the sprites of sprite renderer. This works fine with still images but does not with animations. I want to merge the sprite of base player with the sprite of an eye to make a single sprite. So I have two sprites and I want to make one sprite out of that and then let the sprite renderer render that sprite. Is it even possible? If so, how?

Unity WheelCollider falling through everything

I'm building a 3D car game by using Unity 3D, there are four wheels inside my 3d car model, I created 4 empty gameObjects , put them in the car gameobject and thier position are match with per wheel I added a wheel collider inside each of them but when I ran the game, my car fallig through the terrain. Anyone tell me why?
1:make sure your gameObjects is add collider with another objects
2:check your GOS position in u3d
ps: if you can show the pic on your question , that would be good for your question!!