i have a 2d game with this problem taking up all the time… i know its simple to you guys. but i cant seem to find a way to check so i could stop the animation of the background, ive used GM.Player.rigidbody2d.velocity.magnitude == 0, initialdistance > distance, and many more… i probably am doing something wrong with my code…can anyone help me?
this is the code for the background scrolling.
public class ScrollMidBackground : MonoBehaviour {
public float speed = 0.03f;
private GameManager GM;
private float initialDistance = 0f;
void Start()
{
GM = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameManager> ();
}
void FixedUpdate ()
{
if(GM.taptostart==true)
{
transform.Translate (speed*-1, 0 , 0);
}
if(GM.isGameOver)
{
speed = 0.0f;
}
}
}
// ive deleted all the codes concerning on stopping the movement with the use of my previous codes above.