Hi,
Somehow this part of my code is being ignorded: && Difference < 0.5f
When I use == instead of > it functions properly.
void Update ()
{
float Difference = player1.transform.position.x - transform.position.x;
if (Input.GetKeyDown (KeyCode.Space) && Difference > 0.5f)
{
Debug.Log (player1.transform.position.x);
Debug.Log (transform.position.x);
Debug.Log (Difference);
}
}
The Debug.Log (Difference) shows that when Difference > 0.5f the if statement still is ‘true’.
Can somebody please help me with my problem?
Thanks in advance!
Have you checked that the script is not attached to another object in your scene? Maybe the "if" is true for that object. Add a line like the next one to make sure it happens in the object you think it's happening: Debug.Log(name);
– DiegoSLTS