- Home /
Colliding with mesh works on top, but not sides
Hello I have created a temple like structure made with multiple cubes and cones in a 3d program, then I saved it as .3ds. Through trial and practice, I have also made a cube directly in Unity3d, and added a rigidbody, and the collider is already on it. I collide with the cube fine, however my temple, also having a rigid body and all the different polygon structures having colliders (I have tried cube and mesh) it allows me to walk directly on the surface however when I am on the ground and press my character against the side of the wall, I go through it. My question is how is it I can walk ontop of it, but still go through the sides as though no collision is beeing realized by the program.
Answer by Joshua · Jun 25, 2011 at 02:26 PM
Without code I can only guess to what the reason is, but here goes.
For 'standing' on something you use the physics engine, which applies a constant downward gravitational force. If the physics engine detects collision, it won't let you fall though.
for 'walking' however you don't use the physics engine, you directly set the transform. Meaning you basically teleport the cube a tiny bit forward/backward each step, without checking if something is in it's way.
As quoted from this page: "Generally, you shouldn't manipulate the Rigidbody and the Transform of the same GameObject - only one or the other." Your best solution here would be to move the cube through the physics engine, by adding a small forward/backward force.
Answer by Spittin_fire · Jun 25, 2011 at 03:53 PM
Thank you sir Joshua for your time, What is going on, there is no cube that moves, and I have written no script for these events. The only thing that moves is my character, by code of input, I have a test cube to see if I can collide against it correctly, and I do, I cannot go through its sides or from the top, the structure made of many cubes is my problem. I go through the side of its walls though stand on top of it withought going through it. I have indeed read the page you linked me to many times to see if there is some key element missing, but I am blind to what it is. What you say, move the cube with the physics engine, is there a way I can make my character move against the wall instead of through it with the force element? If coding is the key, I code in csharp, but like I said the only code I have used so far is to make my character move... thanks again!
While messing around I uploaded another model, gave it a mesh collider, and well... its doing the exact same thing. I can go through the sides, but stand on top of it without fallin through..
Your answer
Follow this Question
Related Questions
Problem with Object collision 1 Answer
Mesh Filter Cosmetic Damage 1 Answer
Character Controller goes through objects 2 Answers
Rigidbody not colliding with walls 1 Answer
How to create a 3D object (terrain) using imported data (CSV, txt)?! 2 Answers