Question by
kingofstreets · Feb 04, 2017 at 05:27 PM ·
2d gamewrapwrapping
2D screen wraping problem Javascript
ok so i'm working on a 2D game and i want screen wraping and with this script the character will go beyond the point of witch it is supposed to wrap to the other side and then wrap at another point and i cannot for the life of me figure out why. i feel like it's super simple but idk why it's not working.
function FixedUpdate () {
if(transform.position.x <= -0.597) { //this part works fine
transform.position = new Vector3(0.597, transform.position.y, transform.position.z);
}
else if(transform.position.x >= 0.602) //this side goes to like 0.799 then wraps
{
transform.position = new Vector3(-0.477, transform.position.y, transform.position.z);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612110327im_/https://answers.unity.com/themes/thub/images/avi.jpg)