- Home /
How do I make my object follow the ground perfectly?
If I have a piece of hilly terrain, how can I make my character slide over that ground perfectly, never letting go? I would like this to still be using Unity's physics engine, even to the point of gravity affecting motion up a slope, but not to the point of ever removing the character from the surface.
Just looking for a confident lead to follow up, not specific instructions.
Cheers
Edit - Clarifying: The terrain will be not only hilly, but also with walls, overhangs and ceilings. So while travelling on a wall, gravity will feel normal and pull the player down the wall's surface, but not off the wall. While travelling upside down on a ceiling, gravity will have nowhere to pull the character - neither along the ceiling nor off of it - and the character will remain connected to the ceiling.
If anyone knows James Pond 3, pretty much exactly that.
Well gravity is still an important value, so that would create issues. I updated the OP to be more clear.
Answer by gribbly · Mar 21, 2013 at 08:04 AM
I would use physics. Do something like:
Go to project settings and set gravity to be much higher than normal (normal is -9.8m/s in the y axis)
Use really low friction between character and terrain (so you can slide)
Constrain rotations (so physics is used for translation, but your character can't tip over)
And possibly add some script to zero out rigidbody.velocity.y every frame (e.g., in FixedUpdate()).