How do I stop two gameobjects from going through each other on unity3d - unity3d

I have tried every from unchecking the matrix box , and removing the sphere collider . The problem I am having is the gameobjects wont stop going through each other .I dont know what is going on . I have a pic of what is going on : enter image description here

First of all, don't remove the colliders and make sure they are not set on Is Trigger (that makes the collider penetrable). Also, you are using sphere collider for quite a complex mesh, so I'd recommend using MeshCollider, which would generate it according to the mesh.
Secondly, recheck how you move the objects. If given too much force, it might bash through another collider and not get out of it (imagine that you breaking through a barrier and inside it you cannot get enough speed to break out of it again). That might happen if you use AddForce() and not increasing transform.velocity.
Thirdly, what controls these gameobjects? Player or NavMeshAgent? Because, I think, if they are controlled by AI (NavMeshAgent), they should avoid each other in their paths and shouldn't collide. However, I might be wrong on this one.

Related

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

Unity - How to give some flexibility to colliders

Hi I'am new to Unity and I was trying to implement a game using tetris blocks.
The game's goal is to build the highest tower before it collapses. However there is a problem in my implementation which is seen in the picture below.
I achieve the building a tower task by activating the rigidbody gravityscale when it collides with something. With that way it can collapse after touching somewhere not before. But I want to have the flexibility of some collisions. In the situation seen in the picture below, that 'T' block will collide with the point in the red circle before landing safely and gravityscale of the rigidbody will be set. So it will drop but I don't want it to happen becasue the collision area is too small. I want to make it land safely with some flexibility.
I tried to make colliders' size 0.9 but that just disrupts the scale of the world.
Can I do something like this :
If collision happens, check collision area and if the area is lower than lets say 0.1, do not trigger rigidbody gravityscale.
what about using capsulle collider 2D with small radius?

(Unity 3D C#) Conveyor Physics

So, i am trying to create a flat conveyor that a block will sit on and move, but i want to have it be able to turn, so i cant use rigidbody.moveposition, ive tried using addforce, but i cant get it to work properly without using impule or velocity change, because then it makes the ore roll (they are cubes). my most recent attempt was using velocity, but im not sure how to make it keep its old velocity when changing corners so it doesnt screw it up.
.
If this doesn't make much sense, here is a better explanation, i am trying to create a conveyor system on a grid, where each slot has a direction, and an cube travels along it, whenever the cube reaches a turn, i want the cube to keep moving forward a short distance so it doesn't just immediately change directions and go along the new conveyor, because this way, it will immediately change and will sit on the edge of the conveyor, and not keep moving in the direction.
edit: i currently have it working, my now issue is the cubes will bounce when touching the conveyor, so they wont stay flat against the conveyor, i can fix this by constricting all the cube rotation, but then it will sometimes freeze the ore on the conveyor, not allowing it to move.
since you didn't provide code, I don't know what you are trying to do, so I will give my own solution:
object.transform.position = Vector3.MoveTowards(target.transform.position, endpoint.position, Time.deltaTime * speed)
Then, when it collides with it, it can turn off this script, so it stays at the end.
target is what you want to move, endpoint is where you want it to end up.
Make endpoint a gameObject, and put it at the end of your conveyor, so the objects will move toward, and it will look like a conveyer.

Unity3d - Player flips after a specific chunk

So, I've made a very simple game, which all you basically do is glide through the terrain and avoid the obstacles (I haven't implemented obstacles yet). And I've encountered a very strange problem. When ever I hit the fifth chunk, the player starts to flip:
Can anybody help me find what the problem is and how can I fix it?
Edit: I solved it by using creating a physics material with 0 friction annd applied it to both the chunk and the player.
This could be an issue with your colliders being just a tad too big. check the dimensions of your player's box collider and see if it is bigger than your player. If so make it fit to just inside the outer edges of the player box. Also, unless you ever plan to flip the player intentionally, You could always just apply a constant downward force (Rigidbody + gravity usually will suffice) to keep this from happening. Hope that helps!

Getting Skybox to change on collision in unity with UnityScript?

I'm quite new to UnityScript as my area of interest is python, however me and a friend are planning to create a small indie game and I need the skybox to change on collision in unity. I would prefer this to be done in javascript if at all possible. Please take a look at it and let me know whats wrong with it, as when run it makes no difference to the scene.
#pragma strict
var mat:Material;
function OnTriggerEnter(trigger: Collider){
RenderSettings.skybox=mat;
}
That is the entire script. Thank you for any help given
make sure that for your objects that collide... typically one must have a static collider (e.g. floor, wall) and the other a collider and rigidBody to hit it (e.g. player, car). Also check your physics settings to make sure the layers that the objects are in, can hit each other.
Make sure you have your script on the right object... collider or collidee ? try putting a script on both objects with a print in each.
Check here for more info
http://docs.unity3d.com/Documentation/Manual/Physics.html
What exactly to you mean by changing on collision? Skyboxes cannot be collided with. If you mean objects colliding other than the skybox, make sure that at least one of the collider's has "Is Trigger" checked in the inspector.