The if statement is being ignored in the following code:
public class newscript : MonoBehaviour
{
private float oldPositionx;
void Start()
{
oldPositionx = transform.position.x;
}
// Update is called once per frame
void Update()
{
Debug.Log("the oldPositionx is " + oldPositionx);
Debug.Log("the current transform.position.x" + transform.position.x);
if (transform.position.x != oldPositionx)
{
Debug.Log("if this is shown it's not working");
}
}
}
I have checked the console and the values being compared are equal, so I cannot figure out why the if statement is not working.