Search Unity

Enterable object

Discussion in 'Physics' started by StegnerGames, Dec 4, 2017.

  1. StegnerGames

    StegnerGames

    Joined:
    Feb 26, 2017
    Posts:
    14
    I have a maze I made with Blender and when its in Unity, I have made it solid by adding a rigidbody and mesh collider but I cant enter the maze because the collider blocks the entrance.

    Also when I touch the maze, it moves the whole thing. To try and fix that, I constrain the rotation and position but that allows me to move through the walls.
     
  2. Deejayfistfang

    Deejayfistfang

    Joined:
    Dec 4, 2017
    Posts:
    8
    Hello. Most likely if it is Convex it will make so there are no inner-parts, essentially making a box collider. You have to turn off Convex in the Mesh Collider Component. If you want the Maze to not move don't set the constraints, set the Rigidbody to IsKinematic. If that doesn't work you can try setting the AngularDrag and Drag to 1000 each. It depends on what sort of controller you are using that it would collider with.
     
  3. StegnerGames

    StegnerGames

    Joined:
    Feb 26, 2017
    Posts:
    14
    Ok, I did what you said but now the play can go through the walls. I have some boxes in the game that the player can move around by pushing them and they collide with the maze just fine.
     
  4. Deejayfistfang

    Deejayfistfang

    Joined:
    Dec 4, 2017
    Posts:
    8
    So you're using a Rigidbody Controller as the player, the player's collider hits the boxes and the boxes hit the maze, but the player goes through the maze? Check that all gameObjects with colliders on them interact with physics (Edit -> Project Settings -> Physics). If the player can push rigidbody boxes but not collider with the maze, it could be the layers.
     
  5. StegnerGames

    StegnerGames

    Joined:
    Feb 26, 2017
    Posts:
    14
    @Deejayfistfang
    Thats correct.

    In my player controller script, I'm using
    Code (CSharp):
    1. transform.Translate();
    I read somewhere that that could be the problem. Is that the problem?
     
    Last edited: Dec 8, 2017
  6. StegnerGames

    StegnerGames

    Joined:
    Feb 26, 2017
    Posts:
    14
    This is still a problem. Anyone know how to fix it?
     
  7. Deejayfistfang

    Deejayfistfang

    Joined:
    Dec 4, 2017
    Posts:
    8
    Translate does not use Rigidbody from what I know, it uses transform. Transform movement and Rigidbody movement should be used exclusively from one another. I'm not sure, I use rigidbody.velocity to move my controller characters.
     
  8. StegnerGames

    StegnerGames

    Joined:
    Feb 26, 2017
    Posts:
    14
    When I try that the player doesn't move at all.
     
  9. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    You'd have to have a rigidbody on the player, and make sure all of the code is changed from translate to velocity (or addforce) -- something "of physics".
    There is also the character controller as an option, which is a little bit different and uses its own move. It handles some collisions but not all of the same physics that a custom rigidbody character would; not without extra modifications.
     
  10. StegnerGames

    StegnerGames

    Joined:
    Feb 26, 2017
    Posts:
    14
    So I got it working by remaking my player controller script by following this tutorial:
     
  11. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Cool, good stuff :)