- Home /
Basic unit movement woes, a little help greatly appreciated!
Working on an RTS with Mecanim-animated units. The controllers work, the pathfinding works, I've almost got the basic framework upon which to base all my units.
However, when the units begin moving, I get some moon gravity stuff going on.
I'm familiar with rigidbodies, but here's the problem: If I turn on "Use Gravity," my character falls forward on his face as soon as he starts walking. If I then try "Is Kinematic," he starts running through terrain and causing other clipping issues.
I need my units to reliably stay upright while moving along the surface of a curved terrain in a predictable manner. This seems like a simple issue but I can't figure it out... Programming is more my forte, I flounder a little when it comes to animation and 3D stuff. Any tips?
For your "falls over forward on his face" problem, have you tried Constraints -> "Freeze rotation" options in your Rigidbody component? I usually lock them all and handle the rotations manually somewhere in code.
I gave that a try, but it seems to have no effect, he still just topples over when he starts walking.
That's odd. Could be a problem with hierarchy of the objects, because that shouldn't happen if you freeze the rotations. Could you show a picture of object inspector of the object where Rigidbody component is attached?
I went to get a screenshot and the rotation freeze decided to start cooperating. It seems like the falling over issue is resolved, though now when he sprints up a hill, the vertical offset in the terrain pushes him backwards. He runs a few feet uphill and bounces several feet back... $$anonymous$$aybe just some pathfinding parameter tweaks, you think?
That could be so many things. It's hard to say what is going on unless I see a bit more of the occurring problem (code, inspector view of the object and/or maybe a video of what is happening).
Answer by growling_egg · Jun 13, 2014 at 06:19 PM
I did away with the whole rigidbody/collider mess, added a Character Controller, and magically it all works. I have some other (mostly unrelated) questions now but I'll save them for a different post.
Answer by OllyNicholson · Jun 13, 2014 at 03:53 PM
Hi - this could a be a number of things, so whilst not exactly the definitive answer you might be looking for, I would take a look at how they do it with the new sample assets. Also linked is my character tutorial to run through how to setup your character with these scripts:
https://www.assetstore.unity3d.com/en/#!/content/14474
http://blogs.unity3d.com/2014/04/14/turn-your-character-into-a-player/
Thanks man, looking at the sample assets steered me in the right direction.
Your answer
Follow this Question
Related Questions
Gravity does not work with animation. 2 Answers
Animation clip removed when isKinematic is unchecked 0 Answers
My Mecanim-Generic is screwing with the gravity 2 Answers
Go to sleep. 0 Answers