I started my first Unity3D project and in this game main hero should be able to fly up passing clouds and then reaching open space but i faced with the problem. No matter how long and fast i am flying after takeoff the skyline continues to stay on the same place. Currently i'm going to rotate the main hero so that skyline would go down. But maybe someone can suggest me more common and better way to achieve the effect of leaving the Earth?

I think it would be bad idea to post all my code here because there is a lot of code that does not relate to the topic. But i will try to explain what i'm doing now and i will show you short piece of code. I have global parent object and a main hero is added as a child to it. Then when as main hero moving up relative to the global object i start to rotate this global object around z-axis so that gradually the main hero is looking to the sky.

And for skyline i'm using procedural skybox.

I hope this piece of code will explain better of what i'm doing now:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour
    float gravity;

    GameObject global;//main hero’s parent

    Vector3 startHeroLocalPos;//start hero position relative to the global object

    public float degreesPerUnit = 1.0f;//global object will rotate by this amount of degrees after the player has moved up by one unit

void Start ()
    global = GameObject.FindGameObjectWithTag ("GlobalObject");
    startHeroLocalPos = transform.localPosition;

void Update ()

    float curAngle = (transform.localPosition.y - startHeroLocalPos.y)*degreesPerUnit;
    global.transform.rotation = Quaternion.AngleAxis(curAngle, Vector3.back);

  • \$\begingroup\$ Are you trying to move the skybox? It's a bit difficult to tell just what you are trying to achieve. \$\endgroup\$
    – Sturlen
    Nov 3 '15 at 15:50

A skybox is not a standard mesh and does not behave like other meshes.

A skybox does not move (relative to the camera) when you're moving the camera, this way it simulates being very far away.

You'll likely want some kind of large cylinder around the player, maybe have the X/Y (with Z being up, I don't know what coordinate system unity uses) position set to the camera's position every frame.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.