I have a piece of script that causes an object to fall in ticks of 1 second by one meter. However, something is wrong with it, the object just shoots straight down and I can’t see the logic error, if you guys could point out the issue that would be great!
Here’s the function:
void Fall()
{
if (posit != limit)
{
float pastSecond = 0;
float currentSecond = Time.time - pastSecond;
float nextSecond = 1;
if (currentSecond >= nextSecond)
{
transform.position -= new Vector3(0, 1, 0);
pastSecond = Time.time;
}
}
else
{
return;
}
}