Hello, I am currently working on the junior programmer pathway in unity learn and am working on the top-down game. I am on the step where you create a boundary for the player by using an if statement but whenever the player seems to hit the boundary it teleports to the bottom of the screen and can also still go right, and I have no idea why because my code seems like it’s exactly the same as the instructors.
My player-controller script:
Please help!
so if its < -10, then it sets it to -10 and then moves it again anyway?
yeah, it prevents it from going left but teleports it to the bottom of the screen
oh and also the player can go right and the boundary doesn’t stop them
because there is no code to stop them going too far right… how do you think you might add that?
Probably the same way but with positive 10… But I still don’t know why it teleports to the bottom of the screen
well, one thing is to look at that transform.position statement. the parameters are x,y,z…
so if x is <-10, youre now setting z to whatever that x value is?