0

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.

4

1 回答 1

2

我无法想象你的例子,顺便说一句:

我认为问题是,可能有一些滞后吗?就像上面代码中的更新被调用一帧太晚了?我尝试从第一人称控制器鼠标外观脚本中调用该更新,但是除了得到大量错误之外,结果是相同的。

您不能依赖Update引擎调用方法的顺序(除非您强制执行特定顺序,但这通常不是一个好的选择)。对于相机更新操作,最好使用LateUpdate。保证在所有方法之后都会调用它Update

于 2013-10-02T15:09:04.977 回答