- Home /
Player flies up into the air when walking
I have a character I'm using for the player, with a character controller and movement script attached. I also have an imported terrain model that the player is supposed to walk around on. But as soon as I press the up arrow key to move forward, my character gets launched into the air up to a certain height, and stays there. I've never had this problem before, and I've used these exact same scripts for the player in a different game and they worked fine. I even used the same character. I never had this problejm. The only thing that's different is the imported terrain model. I tried using rigidbodies, I made sure I was using gravity in both the rigidbodies AND the project physics, I tried a different movement script and I made sure there were no other colliders on my character except for the character controller. Nothing helps. Also, when my character shoots up into the air, she starts to fall back down but stops, and just floats there. If I keep moving, she starts to fall at certain points but goes back up to the same height. And everywhere I go, wherever the terrain slopes upward, my character does too, meaning she always stays at the same height above the ground. Even when I walk into the wall of a bulding, she flies up even further and stays above the roof at the same height she was from the ground. It's almost like there's an invisible layer covering the entire terrain, and everytime I move I just pop up to the top of it. Can someone please help me figure out what's causing this? Is there something I'm not checking?
@TheGoliath Is there a mesh collider on the imported terrain model. This sounds like what would happen if the mesh collider is set to convex.
What difference does it make if the mesh is convex? What does that do
No, I haven't applied any kind of collider, except for just checking "Generate Colliders" in the inspector. But when I don't do that, my character just falls through the floor. And honestly, what script would I post? The movement script I'm using has never given me any problems before, and I already tried a completely different one. The same exact thing happened.
I was asking to see your movement script. Have you just tried using the character controller movement call? Or is that what youre using? It calls GetAxis which then you manipulate the speed upon the framerates. All you need is that, make sure you have your CC attached to your char and the terrain has a mesh collider to make the CC respond. Thats it. I literrally just did this to a project i made and all works great. If you already knew this, excuse me for preaching to the choir. =)
Answer by Seth-Bergman · Apr 30, 2012 at 04:16 AM
is your character controller properly sized to your character? Try hitting play, then pause, and see if it stays properly lined up with the character. Otherwise, it may be a problem with the export from 3ds or whatever you're using, in which case make sure the character is at the zero position when you export, just a guess.. If you think the terrain might be the issue, replace it with a big box or something and see if that fixes it, in which case it may indeed be the mesh collider.
Answer by TheGoliath · Apr 30, 2012 at 04:09 PM
I finally figured it out. My terrain was TINY when I imported it, so I sized my character down to match it. It turns out that was the problem. I made everything a lot bigger and now my character stays on the ground. I still appreciate you guys trying to help though, thank you.
Do you think the problem came due to when shrinking the character you also moved its reference to the terrain?
Answer by Lokiare · Nov 08, 2014 at 02:45 AM
I ran into this problem and it has to do with the difference between your navigation height when you bake and the height of your Nav Mesh Agent on your model. You can fix it by offsetting the Nav Mesh Agent on your model, I don't know if this affects path finding or whatever.