# Space game scene boundaries

I've been trying to add boundaries to my space game.

I've been following this tutorial with a sphere instead of a cube, but every time I start the game and move or rotate my ship it appears outside the sphere, as shown in the image:

The ship has a collider and a characterController.

Could anybody tell me what I'm doing wrong here? Thanks!

• It looks like you've misunderstood the tutorial. The tutorial was not showing you how to create a space the player cannot leave, but how to create a space the player cannot enter. They used this non-enterable space as a wall to "plug" an open edge od their map that the player could otherwise walk off of. – DMGregory Sep 27 at 17:02
• I see, I misunderstood then. I already have an answer as how to restrict the movement when you are further from a radius. But out of curiosity, there is any way in Unity that would allow an object with collider to be inside another and still have collision with the outer one? – Hector Sep 28 at 17:30

sphere restriction all means a distance from center point.

Vector3 center = new Vector3(0, 0, 0);
float thresholdDistance = 200;
private void Update()
{
if (Vector3.Distance(transform.position, center) > thresholdDistance)
{
transform.LookAt(center);
}
}


this code make the player to return to sphere zone when is further than a distance from center.

• Interesting, at first I was thinking more in using an impassable sphere because maybe It could be more visual when arranging the scene in Unity, but honestly this way seems better. Perhaps I might use another way to show the player that further travel in that direction is forbidden, like a message or just stopping the movement. But I like It, thank you! – Hector Sep 28 at 17:20