I’m having a lot of trouble with getting collision detection the way I want it. I have a player, which is just a cube and a move script, and i have some walls, which are cubes. The walls are on a plane, which is the floor. I want the player to stop when he hits the walls. I tried making the walls rigidbodies and colliders but they would fall over when the player ran into them. I just need some general help or some general explanations of collision detection. I tried looking at resources and tutorials. Thanks in advance!
Give the walls rigid body components and untick the “use gravity” box. Set the drag in the rigidbody to “Infinity” (literally type Infinity instead of a number). Possible try increasing the mass too - but make sure the masses of your objects are within 900 of each other.
Just like GesterX have said. Put rigid body component in the wall and check the ‘is Kinematic’ property, in this way your wall wont b affected by the physics gravity any more.
Making the walls rigidbodies is silly; make the player cube a rigidbody. Generally, actors in Unity either have a character controller or a rigidbody.
The problem I keep running into is that the player can still push around the walls, which I don’t want. I cant seem to figure out how to make the player unable to move the walls
player: rigidbody/collider/movement script (probably want to set freeze rotation and freeze position on the rigidbody so it can only be moved deliberately by you through script)
walls: colliders, no rigidbody.
It sounds like you need to understand the roles of certain objects in Unity3d better.
Perfect summary right from Unity (read this and you should have no further questions, but if you do feel free to ask again:) ):
http://docs.unity3d.ru/Components/comp-DynamicsGroup.html
Something is really just not clicking for me. Im new to unity and I can’t seem to make it work the way I want to. Is there a specific way the move script is supposed to work? Am I supposed to use OnCollisionEnter?