سؤال

I'm messing around in unity3d in order to learn it.
Had a crack at making my own 3d skybox like in source engine for example. I'm using the standard 1st person controller.
I made another camera with same FOV for my skybox, and slaved it to the camera in the 1st person controller using the script below which I put on my skybox camera.
(Maincam field has the 1st person controller camera component in it)

using UnityEngine;
using System.Collections;

public class CameraSlave : MonoBehaviour {

    public Component Maincam;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    transform.rotation = Maincam.transform.rotation;
    }
}

You can see result here. Its a bit funny. (The big tetrahedron shape in the background is in my skybox everything else is normal)
As far as I understand it as long as the camera fov is the same it doesnt matter what size my skybox things are.
I think the problem, is there is some lag maybe? Like the Update in the code above is being called one frame too late? I tried calling that update from the 1st person controllers mouse look script but as well as getting loads of errors the result was the same.

هل كانت مفيدة؟

المحلول

I can't visualize your example, btw:

I think the problem, is there is some lag maybe? Like the Update in the code above is being called one frame too late? I tried calling that update from the 1st person controllers mouse look script but as well as getting loads of errors the result was the same.

You can't rely on the order in which Update method will be called by the engine (unless you force a particular order, but this isn't generally a good choice). For camera update operations it's better to use LateUpdate. It's guaranteed that it will be called after all Update methods.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top