- Home /
Transform.translate stutter - Android game
Hello! I'm making a very simple 2D vertical scrolling game in which the player simply moves left and right to avoid obstacles. I managed to make the player movement, the background and other stuff but I'm struggling to make the obstacles move flawlessly down; this is the script that is attached to every obstacle, it simply moves it down:
function Update () {
//transform.Translate(0,speed*Time.deltaTime,0);
transform.Translate(Vector2.up * speed * Time.deltaTime);
}
function OnTriggerEnter2D(coll: Collider2D) {
if (coll.gameObject.tag == "Border"){
coll.gameObject.GetComponent(UpdateScore).UpdateScore();
//Destroy(this.gameObject);
this.gameObject.SetActive(false);
this.gameObject.transform.position.y=this.gameObject.transform.parent.gameObject.transform.position.y;
}
}
It resets the object position and updates the score when it hits the bottom border object. It should be easy but for some reasons when I play the preview the obstacles object seem to work fine but sometimes stutter while moving down; I'm sure it's not my pc because that also happens on my Nexus 7 and also the draw calls are around 7-10.
Does anybody know a way to make the stuttering disappear? I'm targeting android.
P.S Could it be something with collisions? my obstacles all have a 2d collider which I use to check if the player is hit or if the obstacle has reached the bottom.
Thanks in advance for any answer ;)
Your answer
Follow this Question
Related Questions
force traslation 1 Answer
transform.Translate not working after exporting to Android 2 Answers
Rigidbody Sink into BoxColider 0 Answers
Moving character on x axis 1 Answer