Open GrazBon opened 11 years ago
The following code will stop the spaceship from keep going left to right out of screen
var border:float=1.0;
if (transform.position.x < BorderController.leftmost + border)
{
transform.position.x = BorderController.leftmost + border;
}
if (transform.position.x > BorderController.rightmost - border)
{
transform.position.x = BorderController.rightmost - border;
}
Spaceship is exiting screen from left to right and vice versa