I need to restart a loop with some variable changed. I’ve tried this but the loop stops without changing anything:
void CheckTrajectory(Vector3 target)
{
Debug.Log("checking");
loopEnd = false;
angleJump = 0;
while(angleJump < 90f && !loopEnd )
{
Scan(target);
}
if(angleJump < 85)
{
rigidbody.velocity = BallisticVel(target,angleJump);
} else
{
//Calculate No Arc
}
}
void Scan(Vector3 target)
{
angle_jump = CalculateAngle(target);
startingVelocity = BallisticVel(target, angle_jump);
heightTime = startingVelocity.y/-Physics.gravity.y;
for (int i = 0; i < heightTime*60; i++)
{
Debug.Log(i);
Vector3 trajectoryPosition = TrajectoryPoint( transform.position, startingVelocity, i );
Debug.Log(trajectoryPosition);
Debug.DrawRay(trajectoryPosition,dir,Color.red,10f);
RaycastHit hit;
if(Physics.Raycast(trajectoryPosition,dir,out hit,collider.bounds.extents.z,mask))
{
angleJump +=10;
Debug.Log(hit.collider.name);
break;
}
else if(i == heightTime*60)
{
loopEnd = true;
Debug.Log("endloop");
}else
{
Debug.Log("continuing");
continue;
}
}
}