Ok, so, what is happening is, i SmoothDamp a number, and then it reaches its goal. When i check that its reached its goal with an if statement, it evaluates to false sometimes, even after its reached its goal.
Script:
var yVel = 0.0;
var smoothPos = Mathf.SmoothDamp(transform.position.y,
initialPos - (height + .1), yVel, .01);
transform.position.y = smoothPos;
if (transform.position.y == (initialPos - (height + .1)))
{
//renderer.enabled = false;
isActive = false;
deactivating = false;
}
The position ends up being the desired value (In this case: initialPos - (height + .1) )
Most often the if statement evaluates to false once the smooth is done.
And to verify i even tried debugging by printing the transform.position.y and the (initialPos - (height + .1)) and they are indeed equal once the smooth is finished. Yet the if statement evaluates to false. Lol.
Any help would be greatly appreciated. Thanks!