c# - Unity Vectors Equality -
{ hi guys, here's problem, pretty new on programming in unity , i've made first game android. it's pretty simple 2d game infinite down scrolling , have dodge fallings blocks. have made little c# script should make player go opposite side of screen when goes out of it. thing is working pretty when use in unity when port apk file doesn't work @ :(. here's code:
thanks helping me :)
if (player.transform.position == new vector3 (8, -7, 0)) { transform.translate (-15, 0, 0); } if (player.transform.position == new vector3 (-8, -7, 0)) { transform.translate (15, 0, 0); }
you shouldn't use == vector3 variables... they're based on floating point numbers can close each other still not equal.
instead try checking whether player.transform.position.x greater 8 or less -8. game should work more consistently way.
Comments
Post a Comment