Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

first person controller falls through the terrain

Discussion in 'Editor & General Support' started by atmadaenygma, Jan 14, 2010.

  1. atmadaenygma

    atmadaenygma

    Joined:
    Oct 5, 2009
    Posts:
    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

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

    atmadaenygma

    Joined:
    Oct 5, 2009
    Posts:
    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

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

    screenhogdotcom

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

    Vimalakirti

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

    atmadaenygma

    Joined:
    Oct 5, 2009
    Posts:
    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

    Joined:
    Aug 25, 2010
    Posts:
    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

    Joined:
    Sep 29, 2010
    Posts:
    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

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

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    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

    Joined:
    Jun 7, 2011
    Posts:
    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
     
    KombuchaDan likes this.
  13. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    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

    Joined:
    Jul 4, 2011
    Posts:
    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

    Joined:
    Jul 22, 2011
    Posts:
    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

    Joined:
    Jul 4, 2011
    Posts:
    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

    Joined:
    Jul 4, 2011
    Posts:
    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

    Joined:
    Jun 9, 2013
    Posts:
    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

    Joined:
    Jul 8, 2013
    Posts:
    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?
     
    marciodonlima likes this.
  20. Dabrain1238

    Dabrain1238

    Joined:
    Jul 10, 2013
    Posts:
    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

    Joined:
    Jan 10, 2014
    Posts:
    3
    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.
     
  22. KaiTheGamerGuy

    KaiTheGamerGuy

    Joined:
    Oct 17, 2014
    Posts:
    1
    So I have this problem also. It seems to happen when you edit the terrain. It happened to me that my fps controller and prefabs would fall through the terrain after i used the paint height tool. Reloaded my project put it back to normal but then i edited the terrain again and used the smoothing tool and my objects fall through the floor again! pressed undo a few times and it didnt fall through. So I found out it happens when you edit the terrain. No Idea why tho
     
  23. manavdis

    manavdis

    Joined:
    Dec 11, 2015
    Posts:
    10
    Χμμμ! Είχα το ίδιο πράγμα να συμβαίνει, καθώς, αλλά ακριβώς έξω από μια στιγμή είχε been corrected, OK?
     
  24. manavdis

    manavdis

    Joined:
    Dec 11, 2015
    Posts:
    10
    Χμμμ! I've had the same difficulty, but out all of a sudden that's been corrected, OK?
     
  25. manavdis

    manavdis

    Joined:
    Dec 11, 2015
    Posts:
    10
    Pardon me for my Greeks, OK? Either way I am a Greek student, OK?
     
  26. Var_yen

    Var_yen

    Joined:
    Oct 1, 2016
    Posts:
    1
    Hello Guys,

    i have been to trying to build a simple fps using unity but
    i encountered a challenge when i completed a set of scripts. the player or
    character starts moving automatically when i click the play button.
    I tried to uncheck the play on wake for the first person controller but
    it just checks itself when i click the play button. Any ideas as to how to
    solve this problem?? I would like to hear them.
     
  27. lingfengzyc

    lingfengzyc

    Joined:
    Dec 15, 2016
    Posts:
    2
    Hi, everybody I also had the same issue, I luckily solved this by changing the "box collider" to "mesh collider" (I made a cube as my plain) hope it helps
     
  28. manavdis

    manavdis

    Joined:
    Dec 11, 2015
    Posts:
    10
    Men of Unity3D I can't understand why is it that difficult to be following any video's directions and rules to the 100% of it and still have any simple bit of problem on my scripts, eh? I mean OK about me following the directions given inside any tutorial, but does this life has to be this difficult after all, eh? I might include some pictures of those lots errors that I'm getting, k? Because now I am not at my PC, ok?
     
  29. TheRedGuy90

    TheRedGuy90

    Joined:
    Dec 5, 2014
    Posts:
    117
    My Player is at the Player Level, the cube at the NPC Level (I just selected any layer other than Player)
    Both are Kinematic, non-Trigger.
    Still goes through.
     
  30. LittleRainGames

    LittleRainGames

    Joined:
    Apr 7, 2016
    Posts:
    97
    Did you change the Layers Physics? Maybe your character is on a layer that does not interact with the terrains layer.
     
  31. Developah

    Developah

    Joined:
    May 13, 2016
    Posts:
    17
    Yeh, I think its the Unity update. I could be wrong, but once we had a camera problem and got really worried that we'd have to start again. Turns out, all we had to do was delete the camera, and create a new camera.
    I guess, some code does not 'update' unless you remove the old one.
     
  32. TheRedGuy90

    TheRedGuy90

    Joined:
    Dec 5, 2014
    Posts:
    117
    I tried making the Cube a Layer below, and a layer above. Both did nothing.
     
  33. rruplink

    rruplink

    Joined:
    Dec 25, 2017
    Posts:
    1
    I had the same problem. Click on Add Components, go to Physics, and choose a collider (and make sure it is the same size as your plane!)
     
  34. FirePool19

    FirePool19

    Joined:
    Jan 7, 2018
    Posts:
    1
    I found out the answer. If you go to the Mesh Collider in the person there will be a property called Mesh. Select the person's body mesh not the terrain mesh.
     
  35. jpetroni

    jpetroni

    Joined:
    Oct 26, 2022
    Posts:
    1
    Lugo me di cuenta que es un colisionador en forma de cubo quitando este y agregando un mesh collider funciono mejor