Capsule Collider not visible in the scene view? - unity3d

I am trying to hit a ball using a golf club. My golf club has three components (three game objects: handle, shaft and head as shown in the first attached image). Head gameobject's inspector can be seen in the another attached image.
To hit the golf ball, we need a collider. So I put a Capsule Collider at head game object. But I don't see any collider at head gameobject.
The head is shown in the last image.
Why I can't put Capsule Collider at the object?
EDIT:
Thanks for the reply.
I increased the radius but still the same.
I placed a Quad in the scene and put Mesh collider onto it (called AW52Collider). Please see in the
first image. We can see the collider clearly.
But I did the same thing to Club head, as it is also a game object I should be able to put a Mesh collider. But I don't see anything. Why?
Please see in the second image.
One more thing I don't understand is when I put AW52Collider inside Club Head object, I don't see AW52Collider also. Why? Please see in the third image.

Increase the size of your collider, those values do not look like you should see the gizmos at all. Best would be to reset the collider to its default values and then play with them until you are happy.
It is best practice to create a child object with colliders on it. The reason is the placement of the collider. The collider is always centered around the pivot point of a GameObject. But you probably want to move your collider freely or disable a group of colliders manually for testing (or optimization) purposes. Also consider that an object with multiple small colliders as child objects is considered one big collider (rigidbody wise). Source (Compound Colliders)

Just enable Gizmos button and you'll find your capsule collider.
See this picture to know exactly where to find it:
(It's in the toolbar below the Scene tab)

Related

The problem with the correct use of a rigid body in a 2D game

I decided to make a 2D game for the PC on Unity, where the character moves around the stage. But I have a problem with the correct use of Rigid Body 2D.
In this picture you can see my playing field.
https://i.stack.imgur.com/PBhwx.png
I want my character to move around the entire field and when colliding with objects does not go through them.
My field is Tilemap, but I hung the Box Collider on the Grid. Boxing collider surrounds the grid.
But when I use Rigid Body and turn on the game, the object falls through. And if you remove the Rigid Body, then it just goes through objects.
I tried to use different types of Rigid Body, when using kinematic and static, sprite goes through houses.
The way it works is when you attach a RigidBody2D to an object, you give it physics properties, but it won't do anything useful without a collider. If you have an object with collider attached - every other object with collider attached will collide with it.
In your case the player should have RigidBody2D and BoxCollider2D. The ground should have BoxCollider2D, and basically everything you want the player to collide with should have BoxCollider2D. So the houses should have BoxCollider2D as well.
This setup should allow the player to walk on the ground without falling through it, and collider with houses.
Make sure that the collider's area is correct. You can preview it in the editor and edit it if it's not correct.
Also if you want it to work make sure the camera points down and your game setup is alongside Y axis so if there's a rigid body object falling down it falls down on the ground not before/behind it.

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)).

Player falls halfway throufh the floor till the outer edge of collider. instead of the inner edge

As you can see in the included video the player falls over the floortile till the outer edge of the floor. Instead it should stop at the inner edge of the tile so it looks like its standing ontop of the tile. Can anyone help? I cant find anything on the internet regarding my issue.
Im sorry if this is a easy fix. Im a beginner. This for a school project :)
Video: https://streamable.com/99jz2o
enter image description here
Photo of sprite standing on the wrong edge of the tile.
Edit: I went back to the tile palette and redrew the level. This time selecting the game object + bitmap again. Now it works. Probably the reason why it didn't work was that when I drew the level I had not added Tilemap Collider 2D and Composite Collider 2D. Now redrawing with those 2 components added it works as it should!
The problem is with your tile map collider. Instead of using this, set empty game objects as children of the objects that make up the . Then, add BoxCollider2Ds to each one, and add scale them to fit the map. If that doesn’t work, then it is either a problem with the rigidbody, or the box collider, make sure that all of the settings are set to default, then slowly change them back, and you will discover what is causing the problem. Then you can comment on this post what variable changed it.
Your issue is the Composite Collider. The docs specify that they
do not define an inherent shape. Instead, it merges the shapes of any
Box Collider 2D or Polygon Collider 2D that you set it up to use
When you attach a BoxCollider2D or PolygonCollider2D, there is a check box on them that specifies Used by Composite. When checking this box, other fields will disappear as they are now controlled by the CompositeCollider.
To use this collider, make a new object that will hold all your other colliders or make a few that hold sections of your map. Give this new parent object a CompositeCollider2D and give all the children BoxCollider2D or PolygonCollider2D. After this, make sure to check the box Used by Composite on the children Colliders.
Edit: Sorry just saw you were using a Tilemap. Just make the CompositeCollider a parent of your Tilemap while keeping the Used by Composite checked.
Edit 2: I am not too familiar with Tilemaps with Composite Colliders, but one other solution you can try before re-childing is changing the Geometry Type field on your CompositeCollider from Polygons to Outlines.

attempting to pick up Object in unity is invisible but collider box can be seen

For some reason, in my game, i am able to pick up every object i want except my Oar prefab.
It shows in the editor scene that the object is picked up but is invisible, all i can see is the collider box and outlines
When i pick up the sword, it appears in my hand. As you can see, the Oar image is on the ground however, the collider box is in the player hands.
I am trying to make it look like my sword.
If im not mistaken, there is a box collider on both the GameObject(parent) and the model(child). You could try removing the collider for the parent or the child, as having a collider for both might result in some weird behaviour.

How can i add a collider for the elevator to prevent from the character to walk through the object?

The character can enter the elevator but the problem is that he can also walk through the walls from sides and behind.
And if i add a box collider or any other collider/s they will prevent from the character to enter the elevator. It's not my elevator object it was made in blender.
Use Compound Collider instead of Mesh Collider.
Create new empty GameObjects called back, front, right, left, top and bottom
then attach Box Collider to each one. Manually resize and move each one to match the size of the elevator on all sides.
Once that is done, put them in a parent empty GameObject then put that parent GameObject under your elevator GameObject so that the colliders will move/rotate with the elevator. Finally, disable or move the front Collider GameObject via code when you want to allow the player to enter inside the elevator.
The image below shows example of what individual collider should look like and the final look:
These sorts of questions are better off in the Unity Answers, as this isn't a programming question. Please keep that in mind for future questions.
To answer your question though,
Find the mesh in your Project Files in Unity, there is a checkbox for 'Generate Colliders' - check this box and press apply.
Finally, on the GameObject with the mesh, add a MeshCollider component.
If the model is set up correctly, your mesh collider should now use the model for collision.
If this does not work, as an alternative, you can use cubes with colliders and 'build' the collision mesh yourself, and parent the objects to the same object so they move with the lift, before disabling the MeshRenderer component so they will not render.