- Home /
how do i check if the player stop moving/decrease speed/stop moving distance so i could stop the scroll animation background at the back.
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.
Answer by superluigi · Aug 07, 2015 at 02:44 AM
For some reason I can't comment on your question so I'm going to have to post this as an answer, but here's a video that might help you. I'm not sure if it will, but it's worth a shot https://www.youtube.com/watch?v=DIQFhEo1C8c&feature=iv&src_vid=9bhkH7mtFNE&annotation_id=annotation_787378253
Answer by Rhylvin2015 · Aug 07, 2015 at 04:20 AM
thanks but the tutorial is a runner, not an infinite runner. and he uses an Input mouse button to check.. mine doesn't since it runs infinitely and the only Input it uses is to jump. thanks again for your quick response