- Home /
Design/discussion question
What are best practices for getting your character to not fall through the floor?
I've done all of the tutorials on the main Unity site, including the stealth tutorial. Incidentally, the first game I want to make with Unity is also a stealth game, so I'll have a lot that I should be able to borrow from that tutorial. I made my own custom placeholder character model and imported it, as well as the mocap animations from the asset store. When I ran the animation, my character would just fall right through the plane that I created. Okay, fair enough. I didn't give him a collider. I added a capsule collider, just like the stealth tutorial, and now the character wouldn't fall through the plane, but he would roll on the rounded end of the capsule collider until he fell face-forward on the ground in his walk cycle. I double-checked how they handled this in the stealth tutorial, and they just froze the character's Y position. This raised questions for me.
My immediate thought was that this would mean hills would be impossible with this implementation, so I created a second plane that was at an incline to the current one, and just as I thought, the character model ignored the plane and kept walking right through it, even though both objects had colliders. So, my first question is: how do I handle hills this way? It appears that the stealth tutorial just gets the player transform and manually increases the Y position when the player is in the elevator, so this kind of looks like a sneaky shortcut. Is this how it's normally done? Obviously, I could do a full mesh collider for the player model, but as mentioned in the tutorials, that's not very good on performance.
What is the best practice here? Do I freeze the Y position on all of my character models and just manually adjust the height whenever there are stairs or something? Do I make some kind of flat collider at foot height on my character to collide with the scene? Is there something else I haven't thought of?
Answer by robertbu · Oct 06, 2014 at 01:07 AM
Discussion/design questions should be asked on Unity Forums. If you post there, you may want to add a link to this questions so anyone who wants to follow or contribute to the discussion can find the thread.
Follow this Question
Related Questions
Locomotion System tilting character 1 Answer
How can I change animation with colliders? Using AR and Vuforia. 0 Answers
What is the difference between Animator Controller and Animation component? 1 Answer
Problems with Sliding Door Animation (solved) 1 Answer
How do you animate/transition a jogging character to a stop believably? 1 Answer