first person controller falls through the terrain

Discussion in 'Unity Support' started by atmadaenygma, Jan 14, 2010.

  1. atmadaenygma

    atmadaenygma

    New Member

    Joined:
    Oct 5, 2009
    Messages:
    27
    i do not know what happened i am making my game and my city all is well, and now i am detailing and editing, i did no changes to the first person controller, but now no matter what i do and where i put him he just falls, i have re-imported, deleted, and did all i could and he just falls, i even reset. i opened an old project and it still works there but i can see no differences in the settings that makes him fall through, did i do something irreparably wrong or is there something i can do to fix this problem?
  2. WinningGuy

    WinningGuy

    New Member

    Joined:
    Aug 10, 2009
    Messages:
    886
    What if you put the controller about a foot above the terrain when you start? Will he still fall through?
  3. atmadaenygma

    atmadaenygma

    New Member

    Joined:
    Oct 5, 2009
    Messages:
    27
    yea i have tried him in all different locations of the city where once everything worked perfectly, it is something that just started today, i did no changes to anything just general moving and scaling of buildings
  4. VL3

    VL3

    New Member

    Joined:
    Jan 11, 2010
    Messages:
    43
    Did you attach colliders?
  5. screenhogdotcom

    screenhogdotcom

    New Member

    Joined:
    Aug 23, 2009
    Messages:
    126
    If colliders are attached to all objects, could you have turned one of the colliders into a trigger by mistake?
  6. Vimalakirti

    Vimalakirti

    Member

    Joined:
    Oct 12, 2009
    Messages:
    752
    Also, for random errors, if you use transform.position to move your character around, it will move through the terrain.
  7. atmadaenygma

    atmadaenygma

    New Member

    Joined:
    Oct 5, 2009
    Messages:
    27
    basically what i have is this, generate terrain thn i set resolution to my desired size, afterward i set all my prefabs in with generate colliders everything worked perfectly..... until yesterday i see nothing that could have changed, i cannot put the character controller anywhere he just falls i think it is a glitch or something just thought maybe there is a way to do a generall reset to default of the characters without potentially loosing all my hard work, i will see about cutting and pasting all the files to a new project to see if that rectifies the situations.
  8. artbywaqas

    artbywaqas

    New Member

    Joined:
    Aug 25, 2010
    Messages:
    15
    Well this isn't just a random by chance problem. I was teaching a class of 28 students today and we all ran into this problem!? No matter how many times we recreated the first person controller it fell right through the terrain. We tried deleting it out and recreating the controller and every once in a while if we were lucky it would work the way it should.

    There must be a predictable logical reason why this happens and hence a solution.

    Anyone know of how to fix this problem?
  9. Ostagar

    Ostagar

    New Member

    Joined:
    Sep 29, 2010
    Messages:
    445
    artby, falling through the floor is something that happens more frequently when you're new to Unity, atmadaenygma's case perhaps being an exception. In the case of you and your students, the most likely situation is you guys chose poor y-coordinates for the player's starting position--ie, his feet might have begun slightly beneath the ground plain. That's hard to detect without a good camera angle, and that's why WinningGuy was suggesting started a few feet above the floor to be on the safe side.

    Also consider the other possibilities discussed in this thread.

    To debug, drop the player and a cube from high up and see if they go through the floor. If they do, you know to investigate the floor's properties. If only the player does, you investigate the player's properties.
    Last edited: Oct 13, 2010
  10. cscheff20

    cscheff20

    New Member

    Joined:
    Feb 8, 2011
    Messages:
    5
    I'd like to talk this topic personally with Atma. Contact me please.
  11. RHD

    RHD

    New Member

    Joined:
    Mar 30, 2009
    Messages:
    608
    I just imported a project from Unity 2.6 to Unity 3 and now my FPC drops through terrain. All the colliders on the terrain seem to have stopped working. This happens also on the models but those I could add colliders to or re-import. The terrain I do not know how to fix.
  12. straley

    straley

    New Member

    Joined:
    Jun 7, 2011
    Messages:
    1
    Hi All,

    Just in case people are searching for an answer to this, like I was, I had a similar problem. It turns out I set the XYZ of the Main Camera attached to the First Person Controller -- and not the First Person Controller. Make sure that the Main Camera attached to the First Person Controller XYZ is set to 0,0,0 (or something appropriate). Then, set the XYZ of the First Person Controller.

    ~ Scott
  13. RHD

    RHD

    New Member

    Joined:
    Mar 30, 2009
    Messages:
    608
    Thanks for your post. My problem turned out to be slightly different.

    I know of old that if you have the green wireframe set through the floor the FPC will drop through.

    What happened to me when I upgraded my project to 3 was that even though the important green wireframe was slightly above the terrain, the gray capsule (sorry, too tired to look up the correct terminology right now) which was switched off as I didn't want it, was sticking out below the terrain. This hadn't mattered in Unity 2.6 but apparently did in 3. And as it was switched off it took me a very long time to take an interest in it and by trial and error, figure it out.

    It's always the simple things....except when it's the really complicated ones!

    .
  14. OrbitusII

    OrbitusII

    Member

    Joined:
    Jul 4, 2011
    Messages:
    175
    I am having the same problem, and I have all of these things in order (i.e. moving the whole FPC, the capsule is above the terrain, etc.) but it still falls through the terrain. I have even tried making my own FPC, but that still falls through. My only guess is that the Terrain Collider is screwed up by using the terrain toolkit asset package to make the terrain.

    Can anyone help confirm this?
  15. kjartanith

    kjartanith

    New Member

    Joined:
    Jul 22, 2011
    Messages:
    25
    I made cube and made it flat, i put character alot over the "floor", puted the charactercontroller to the character, and my MoveAround script:

    //Moving around
    var speed =3.0;
    var rotateSpeed = 3.0;
    //shooting
    var bullitPrefab:Transform;
    //dying
    static var dead = false;
    //Getting hit
    var tumblespeed = 800;
    var decreseTime = 0.01;
    var decayTime = 0.01;
    static var gothit = false;
    private var backup = [tumblespeed, decreseTime, decayTime];

    function LateUpdate()
    {
    if(dead)
    {
    transform.position = Vector3(0, 0, 0);
    gameObject.Find("Main Camera").transform.position = Vector3(0, 0, -10);
    dead = false;
    }
    if(gothit)
    {
    if(tumblespeed < 1)
    {
    //We´re not hit anymore... reset get back in the game!
    tumblespeed = backup[0];
    decreseTime = backup[1];
    decayTime = backup[2];
    gothit = false;
    }
    else
    {
    //We´re hit! Spin our character around
    transform.Rotate(0,tumblespeed * Time. deltaTime,0, Space.World);
    tumblespeed = tumblespeed-decreseTime;
    decreseTime += decayTime;
    }
    }
    }

    function OnTriggerEnter(hit : Collider)
    {
    if(hit.gameObject.tag == "fallout")
    {
    dead = true;
    //substract life here
    HealthControl.LIVES -=1;
    }

    if(hit.gameObject.tag == "enemyProjectile")
    {
    gothit = true;
    HealthControl.HITS += 1;
    Destroy(hit.gameObject);
    }
    }
    function Update ()
    {
    var controller : CharacterController = GetComponent(CharacterController);

    // Rotate around y - axis
    transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);

    // Move forward / backward
    var forward = transform.TransformDirection(Vector3.forward);
    var curSpeed = speed * Input.GetAxis ("Vertical");
    controller.SimpleMove(forward * curSpeed);

    if(Input.GetButtonDown("Jump"))
    {
    var bullit = Instantiate(bullitPrefab,
    transform.Find("Spawnpoint").transform.position,
    Quaternion.identity);
    bullit.tag = "wormProjectile";
    bullit.rigidbody.AddForce(transform.forward * 2000);
    }
    }

    @script RequireComponent(CharacterController)

    My character falls through the cube, and the same happens if i chanche the cube into terrain. HELP!!!!!!!!!!!!!!!!
  16. OrbitusII

    OrbitusII

    Member

    Joined:
    Jul 4, 2011
    Messages:
    175
    Alright I think I figured this problem out. I dragged the "UH-1N" prefab into the Bootcamp demo level, attached a mesh collider and rigidbody. It still fell. I then looked at the rest of the rigidbody-equipped objects in the level and they had the "Kinematic" box on the rigidbody checked. I checked that box on the UH-1N and it didn't fall through! So apparently you need to check the "Kinematic" box in order for it to actually collide, and make the collision detection "continuous dynamic."

    OrbitusII
    Last edited: Oct 22, 2011
  17. OrbitusII

    OrbitusII

    Member

    Joined:
    Jul 4, 2011
    Messages:
    175
    Also, it is completely essential that you use the layers as they are used in the bootcamp demo, else the colliders will not work. E.G. the terrain needs to be the "terrain" layer, your 1st person controller prefab needs to be the "player" layer, etc. For level objects (like buildings, etc) they need to be the "hit" or "hit 2" layer. This is the solution to this problem. You may need to go into the "project settings>physics manager" and check or un-check certain boxes if you want certain layers to collide or not to collide with other layers, but this step is a last resort in case the layering correction still fails (which it won't, so the only real time you need to change the physics manager settings is when starting a new project).

    This is my final answer, and I have indeed tested this with successful results. Any other possible solutions are unknown to me, so please don't ask.

    OrbitusII
    Last edited: Oct 24, 2011
  18. unnivm

    unnivm

    Member

    Joined:
    Jun 9, 2013
    Messages:
    1
    t may be bit late to see another answer for this. However, I simulated this issue bu just creating a terrain, Firstperson Controller and Directional Light. In terrain I just initially checked isTrigger attribute. This time the fpc, was falling through the terrain. So I uncheked the attribute and found it is working as expected. May this solution will help somebody who is facing this issue. I am using Unity 3.5 to do this.



  19. Cassoulet

    Cassoulet

    New Member

    Joined:
    Jul 8, 2013
    Messages:
    1
    I solved the problem. I applied a rigidbody compoment on my cube(which is also my terrain) and I just removed it .

    Et voilà :) Rather easy na?
  20. Dabrain1238

    Dabrain1238

    New Member

    Joined:
    Jul 10, 2013
    Messages:
    2
    Yes and anybody in the future have this problem... I would just like to add that raising the plane or terrain, and the First Person Controller will most likely solve the issue.
  21. William_Goodspeed

    William_Goodspeed

    Member

    Joined:
    Jan 10, 2014
    Messages:
    1
    I would just like to add a further solution in case you are still experience a problem despite all the solutions suggested above.

    Solution:

    Select your terrain and under the Terrain Collider section ensure that in the Terrain Data field you have New Terrain selected. If you don't just click on the circle to the right of the box and select New Terrain from the pop up window.