- Home /
Question by
iHaveReturnd · Oct 07, 2012 at 06:06 PM ·
physicsgravityartificial
Spherical Gravity Question
Hello,
I'm trying to get a spherical gravity system to work.
Right now I have an empty game object with this script:
var gravity : int;
function OnTriggerStay(hit : Collider)
{
if (hit.transform.tag == "Player") {
var planet : GameObject = hit.gameObject;
planet.rigidbody.velocity += (transform.position - planet.transform.position).normalized * gravity * Time.deltaTime;
}
}
It's at the center of a sphere. I am using the first person controller, tagged as player. The script doesn't seem to have any effect on the player right now. I set the gravity on the first person controller to 0, and the gravity on the empty game object to varying amounts just to see if it worked, but it did not.
It either only falls or floats on a parallel plane.
Comment