Hello everyone!
Its I, Bakos! Again! hahaha
I am having a major issue which is bringing my game production to a HALT.
The issue is:
//
When I add a constant force to an object, to simulate gravity on a planets surface, the character will NOT STOP MOVING! No matter what I do. I’ve tried cancelling out my velocity and angular velocity! I’ve tried putting the rigidbody to sleep. I’ve also disabled constant force entirely, but still, it is constantly moving!
Things i have tried.
//In this first script, i’ve tried entirely cancelling out the attached rigidbody’s velocity/angular velocity and putting it to sleep. But no success.
function Update ()
{
}
function OnTriggerStay (other : Collider)
{
//other.attachedRigidbody.useGravity = false;
var direction = -(other.attachedRigidbody.transform.position - transform.position);
if (other.attachedRigidbody && expStandUp.Grounded == false)
{
other.rigidbody.constantForce.force = direction /3;
}
else if(other.attachedRigidbody && expStandUp.Grounded == true)
{
rigidbody.velocity = Vector3.zero;
rigidbody.angularVelocity = Vector3.zero;
rigidbody.Sleep();
}
}
function OnTriggerExit (other : Collider)
{
//other.attachedRigidbody.useGravity = true;
other.attachedRigidbody.constantForce.force = Vector3.zero;
}
//
//In this next script, i have tried making the constant force = Vector3.zero(AND Vector3(0,0,0). All this did was cancel out the constant force but the character kept moving.
if (other.attachedRigidbody && expStandUp.Grounded == false)
{
other.attachedRigidbody.constantForce.force = direction /3;
}
/*else if(other.attachedRigidbody && expStandUp.Grounded == true)
{
//other.attachedRigidbody.constantForce.force = Vector3.zero;
other.attachedRigidbody.velocity = Vector3.zero;
}*/
if(other.attachedRigidbody && expStandUp.Grounded == true)
{
other.attachedRigidbody.velocity = Vector3.zero;
}
//
I have tried a multitude of methods to cancel out the rigidbody’s velocity as well as stop the character from moving, but it seems that no matter what i do, the character will not stop moving and it doesn’t make sense to me…
I have found out that the only thing that works is to freeze the POSITION(not rotation) of the character, but as you expect, i cannot do that because it would render the character useless.
//
Is there anything i am missing?!
Sorry for the long question, if you skipped to the end read this!!! vvvvvvvvvvvvvvvvvvv
//Issue:
I cannot stop my character from moving.
I have tried using freezeRotation, angularvelocity/velocity = vector3.zero(as well as vector3(0,0,0))
Characters position keeps moving as well as the y rotation of the character.
//
If i am missing anything please help, if not then is there any other method i could use for gravity for a sphere?
//
Thank you for reading!
Sincerely,
Bakos