If a hedgehog run over by a car, a suitable noise is generated and the hedgehog comes back to its starting position! And how can you solve this problem: a car reaches the right edge of the pitch, it reappears on the left !!!!!
Where is your code? what commands do you use to make the car move? what are the name of your classes? what parameters are used to create your world? what have you tried?
It is easy to ask a simple question; but, the only answer that can be proffered with what was given is -- "Use 'if' statements. Beyond that, one would have to guess as to what information you left out.