I added a collider2D component to my Player to collide with the floor, but I noticed that the info panel which contains physic parameters like Friction, Bounciness is grey.I have to create a physics material by myself.So is that what it is(read only)?
image
Those values there are only readable and not able to be written on or to be changed.
Therefore if you would like to change them you need to make a PhysicsMaterial2D and apply it to the CircleCollider2D. You can also change the extents and centre of the CircleCollider2D by referencing the component in a script.
https://docs.unity3d.com/ScriptReference/CircleCollider2D.html
Related
This specific purple colored image with a bit of opacity isn't getting a collider generated around it by TilemapCollider2D
I've tried setting the same settings as the other sprites that don't have this problem but nothing happened. This is also in a brand new project that I've created to test this collider generation only. Everything else is default settings.
TilemapCollider2D relies on a property called ColliderType to determine what shape to draw a collider. Check your collision tile file’s properties, and see if ColliderType is set to None. If so, you can change it to either Sprite or Grid, and it should draw the collider.
For more info:
https://docs.unity3d.com/ScriptReference/Tilemaps.Tile.ColliderType.html
Hope this helps.
I am using tilemap in unity for level building. I need colliders on my tiles. If I add a tilemap collider to the tilemap it generates a collider around the tile, however I need to edit these colliders and have different colliders for every tile.
How could i do this?
Wrong collider:
What i want to achieve:
In your case you have square tiles and the Tilemap Collider box fits it naturaly.
To edit the Tilemap Collider, go to the Sprite Editor in the Sprite you're trying to use and modify how you want it to by clicking in Custom Physics Shape
Then, once you have the right shape, reset your Tilemap Collider and you're good to go.
Updated Answer for newer versions of Unity 2019+:
You now have to open the sprite sheet in the sprite editor and then select "Custom Physics Shape" under the Sprite Editor dropdown.
Your Sprites usually automatically generate a physics shape. You can use Unity's physics shape editor to modify your sprites generated physics shape. With this, you could modify each tile's automatically generated shape. If you're looking for a more tailored shape that is more specific than just the sprite, you may need to build custom colliders that are not tied to your painted tilemap.
I've discovered "PolygonCollider2D" which allows you to make a more precise collision shape. I've made the collisions as a separate Game object.
i've made a simple pot model inside blender:
So the idea is that after importing to unity, generating mesh collider, adding ridgin body i would like to be able to put smothing inside the pot. Now it's generating collider but without a "hole" inside, so if i throw smth inside it just bounce off the top. Is there any way to do it simple way? I'd like to avoid making a collider by hand in unity, using cubes and so...
Image overview:
Your collider needs to be concave
It isn't clear from your question how you're "generating mesh collider," but the results are clearly generating a convex collider.
That said, some things to know about mesh colliders (and concave ones even more so): They are very compultationally heavy to calculate, so they should never...
move
scale (especially non-uniformly)
rotate
...at runtime.
Alternatively you can use multiple box colliders in the same orientations as the side-segments of your can (along with one or two for the bottom, depending on how small of an object you'll be dropping inside).
Uncheck the generate collider box from the import settings, add a mesh collider component and check convex.
I would use four or six box colliders for the walls of the pot and another for the floor. You can scale each box collider along each axis, but if you want to rotate a box collider you will need to give it a parent and rotate the parent. Box colliders are very low cost for the physics engine compared to mesh colliders.
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.
I have a very tall, and thin, tower of cubes one on top of the other, each with a rigidbody attached.
I'm trying to build it higher and higher and have a wind blowing at random heights to try to blow it up and demolish it. It seems simple, but I can't do it properly.
I need to do something as the wind zones for tree, and I cannot attach the forces to the cubes since I need something to instantiate randomly at certain times or places that "pushes" the cubes to make them fall.
I've tried with a particle system, but I was unable to make the particles as collider objects (is this even possible?).
Any suggestion?
Interactive cloth might be your choice.
To add an Interactive Cloth in the scene, click menu
GameObject -> Create Other -> Cloth.
Add new anchor GameObjects (Menu GameObject > Create Empty Object)
For each game object, add a collider component (Menu Component >
Physics > Box Collider)
For each collider, specify the center and size of the collider
For each collider, specify the 3D location of collider, at which the
cloth remains static
Make sure the collider overlaps/intersects with the cloth, otherwise, it won’t work.
For your case, if you wish to programmatically specify the anchor position (since it is random), you might wish to refer to this tutorial as well.