|
Hello! I'm trying to make a custom gravity script and I found one from cheatsguy777 on the forums that does apply gravity. I am getting my models to walk around a planet and the gravity works fine at the top pole. but at the bottom or at the side the model just falls off. I want it to stay normal to the planet all the time and have the gravity applied in the down direction but it doesn't become normal ever. I do have rigidbodies on everything and colliders and gravity is turned off on all rigid bodies. how could i change this script to make it work? I'm putting the script on the player walking around the planet. I've tried putting it on just the planet but that didn't seem to work either. Thanks for the help!
(comments are locked)
|
|
I suggest looking through previous questions asking about relative gravity or Mario Galaxy type mechanics. I answered a similar question a while ago, it'd probably apply to you, too. also, for interest: http://www.gamasutra.com/view/feature/3593/games_demystified_super_mario_.php
Jun 20 '11 at 10:18 PM
Chris D
after looking through alot of that it seems like theres a problem with the character controller. why is that and how does it effect doing raycasts? I could do it with an object but only if there was no controller. That leaves me wondering how i'm going to control the character.
Jun 21 '11 at 02:09 AM
cidmodder
Have you given it a shot with the controller and it's still bugging out?
Jun 21 '11 at 02:15 AM
Chris D
if i do it with any of the controllers it won't rotate the body to be normal to the surface. if i just use the capsule and camera with no controllers then it will turn to be normal to the sphere all the time.
Jun 21 '11 at 07:07 PM
cidmodder
my guess (I haven't looked at the controller code) is that there's a line in the code that's resetting the controller's orientation every frame or locking it altogether...
Jun 21 '11 at 08:24 PM
Chris D
(comments are locked)
|

Do you have Unity's gravity being applied to your character also? Does the character stay normal and just fall off or does staying normal not work either?
gravity has been turned off although everything does have a rigidbody. it doesn't stay normal either
Get the normal of the surface from the collision generated upon the surface of the "planet." Then base the gravitational force on the inverse of that normal and rotate your model accordingly.