- Home /
Unity Height Glitch (explained)
you know when your player specificly one with a MoveArond script from the tornado twins tutorial gets to a certain height in the -y, when you move around, it messes up and you are "bumping" into colliders you never put there? or controls reverse?
i know it happens when the character gets below a certain point on the global y axis. it also happened in the early versions of unity. is this just a general gaming glitch where the game messes up after a certain point?
Answer by Peter G · Nov 01, 2010 at 10:29 PM
How low are we talking? Below a very large point and you will start to get floating point inaccuracies (every place value you go out to the left, you lose one on the right).
Another possibility could be the code itself. I doubt they(aka the tornado twins) would intentionally write code that doesn't work beyond a certain point, or accidentally write code that does that, but without seeing any code I cannot say certainly that there isn't a bug in the code.
I'm also not sure how you got that low, but if you are falling, then the character might exceed a speed at which they can pass through a collider in 1 frame. That's why Unity introduced continuous collision detection. In that case, you have to either limit your character's speed, or use some form of raycasting to ensure that it will not pass through.
P.S. If a "Tornado Twin" views this message, I don't mean to degrade your work in any way. I have a lot of respect for what you guys do helping people new to Unity find the way. I just don't want to rule out something without certainty.
yeah, and actually, i just said their (Tornado Twins) moving script because that was the first one i could think of, but it happens with any script that you use, even a unity pre-script. a character control script that unity comes with. but, i think your raycast idea would work. i'm not saying it's the code, i was just asking why... but you made it clear, so... thank you.
okay, i was working on my game even before tornado twins (before i started watching them) and i had the player fall through a hole in the ground that i made from several planes, just to test unity out (this was long ago...) and even then, the player was moving weirdly, and couldn't even enter an empty space in a hut (two openings- front and bottom) and i checked the players height. it was oh... about -2000. sooo... i guessed it was just a logical thing about unity to stop making movement accurate beyond a point, so that you don't keep going to infinity in a scene.
Not quite. Yes, at -2000 you would experience some skipping, but Unity did not do it just so that you would not make your game go to infinity. It isn't really something Unity can't control either. Think of it like this. Let's say we have an imaginary memory slot for the player position that holds a value with 10 digits. So it can hold from the number 999999999 to the number .000000001 But you'll notice that if you have an extremely large number, the value runs out of space to store a decimal so your player's position will increment from whole number to whole number. This becomes more (cont.)
apparent with vertices in a mesh that are close together and require more accuracy, but are extremely far away from the origin.